aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs230
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs118
-rw-r--r--OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs104
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs14
-rw-r--r--OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs17
-rw-r--r--OpenSim/Services/Connectors/BaseServiceConnector.cs33
-rw-r--r--OpenSim/Services/Connectors/Estate/EstateDataConnector.cs338
-rw-r--r--OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs12
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs121
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs17
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs99
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs57
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs591
-rw-r--r--OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs1
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs405
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs4
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs83
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs72
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs26
-rw-r--r--OpenSim/Services/Connectors/Properties/AssemblyInfo.cs4
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs4
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs526
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs12
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs180
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs118
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs118
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs49
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs119
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs212
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs8
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs13
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs165
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs57
-rw-r--r--OpenSim/Services/EstateService/EstateDataService.cs (renamed from OpenSim/Services/Connectors/Simulation/EstateDataService.cs)5
-rw-r--r--OpenSim/Services/SimulationService/SimulationDataService.cs (renamed from OpenSim/Services/Connectors/Simulation/SimulationDataService.cs)13
40 files changed, 2629 insertions, 1339 deletions
diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
new file mode 100644
index 0000000..1dbc0c8
--- /dev/null
+++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs
@@ -0,0 +1,230 @@
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.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace OpenSim.Services.Connectors
43{
44 public class AgentPreferencesServicesConnector : BaseServiceConnector, IAgentPreferencesService
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private string m_ServerURI = String.Empty;
49
50 public AgentPreferencesServicesConnector()
51 {
52 }
53
54 public AgentPreferencesServicesConnector(string serverURI)
55 {
56 m_ServerURI = serverURI.TrimEnd('/');
57 }
58
59 public AgentPreferencesServicesConnector(IConfigSource source)
60 : base(source, "AgentPreferencesService")
61 {
62 Initialise(source);
63 }
64
65 public virtual void Initialise(IConfigSource source)
66 {
67 IConfig gridConfig = source.Configs["AgentPreferencesService"];
68 if (gridConfig == null)
69 {
70 m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini");
71 throw new Exception("Agent Preferences connector init error");
72 }
73
74 string serviceURI = gridConfig.GetString("AgentPreferencesServerURI", String.Empty);
75
76 if (serviceURI == String.Empty)
77 {
78 m_log.Error("[AGENT PREFERENCES CONNECTOR]: No Server URI named in section AgentPreferences");
79 throw new Exception("Agent Preferences connector init error");
80 }
81 m_ServerURI = serviceURI;
82
83 base.Initialise(source, "AgentPreferencesService");
84 }
85
86 #region IAgentPreferencesService
87
88 public AgentPrefs GetAgentPreferences(UUID principalID)
89 {
90 Dictionary<string, object> sendData = new Dictionary<string, object>();
91
92 string reply = string.Empty;
93 string uri = String.Concat(m_ServerURI, "/agentprefs");
94
95 sendData["METHOD"] = "getagentprefs";
96 sendData["UserID"] = principalID;
97 string reqString = ServerUtils.BuildQueryString(sendData);
98 // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);
99
100 try
101 {
102 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
103 if (String.IsNullOrEmpty(reply))
104 {
105 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null or empty reply");
106 return null;
107 }
108 }
109 catch (Exception e)
110 {
111 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
112 }
113
114 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
115 if (replyData != null)
116 {
117 if (replyData.ContainsKey("result") &&
118 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
119 {
120 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received Failure response");
121 return null;
122 }
123 }
124 else
125 {
126 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetAgentPreferences received null response");
127 return null;
128 }
129 AgentPrefs prefs = new AgentPrefs(replyData);
130 return prefs;
131 }
132
133 public bool StoreAgentPreferences(AgentPrefs data)
134 {
135 Dictionary<string, object> sendData = new Dictionary<string, object>();
136
137 sendData["METHOD"] = "setagentprefs";
138
139 sendData["PrincipalID"] = data.PrincipalID.ToString();
140 sendData["AccessPrefs"] = data.AccessPrefs;
141 sendData["HoverHeight"] = data.HoverHeight.ToString();
142 sendData["Language"] = data.Language;
143 sendData["LanguageIsPublic"] = data.LanguageIsPublic.ToString();
144 sendData["PermEveryone"] = data.PermEveryone.ToString();
145 sendData["PermGroup"] = data.PermGroup.ToString();
146 sendData["PermNextOwner"] = data.PermNextOwner.ToString();
147
148 string uri = String.Concat(m_ServerURI, "/agentprefs");
149 string reqString = ServerUtils.BuildQueryString(sendData);
150 // m_log.DebugFormat("[AGENT PREFS CONNECTOR]: queryString = {0}", reqString);
151
152 try
153 {
154 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
155 if (reply != string.Empty)
156 {
157 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
158
159 if (replyData.ContainsKey("result"))
160 {
161 if (replyData["result"].ToString().ToLower() == "success")
162 return true;
163 else
164 return false;
165 }
166 else
167 {
168 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences reply data does not contain result field");
169 }
170
171 }
172 else
173 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply");
174 }
175 catch (Exception e)
176 {
177 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
178 }
179
180 return false;
181 }
182
183 public string GetLang(UUID principalID)
184 {
185 Dictionary<string, object> sendData = new Dictionary<string, object>();
186 string reply = string.Empty;
187
188 sendData["METHOD"] = "getagentlang";
189 sendData["UserID"] = principalID.ToString();
190
191 string uri = String.Concat(m_ServerURI, "/agentprefs");
192 string reqString = ServerUtils.BuildQueryString(sendData);
193
194 try
195 {
196 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
197 if (String.IsNullOrEmpty(reply))
198 {
199 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null or empty reply");
200 return "en-us"; // I guess? Gotta return somethin'!
201 }
202 }
203 catch (Exception e)
204 {
205 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: Exception when contacting agent preferences server at {0}: {1}", uri, e.Message);
206 }
207
208 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
209 if (replyData != null)
210 {
211 if (replyData.ContainsKey("result") &&
212 (replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
213 {
214 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received Failure response");
215 return "en-us";
216 }
217 if (replyData.ContainsKey("Language"))
218 return replyData["Language"].ToString();
219 }
220 else
221 {
222 m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: GetLang received null response");
223
224 }
225 return "en-us";
226 }
227
228 #endregion IAgentPreferencesService
229 }
230}
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 2b2f11f..bd43552 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -33,13 +33,12 @@ using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications;
37using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
38using OpenMetaverse; 37using OpenMetaverse;
39 38
40namespace OpenSim.Services.Connectors 39namespace OpenSim.Services.Connectors
41{ 40{
42 public class AssetServicesConnector : IAssetService 41 public class AssetServicesConnector : BaseServiceConnector, IAssetService
43 { 42 {
44 private static readonly ILog m_log = 43 private static readonly ILog m_log =
45 LogManager.GetLogger( 44 LogManager.GetLogger(
@@ -55,6 +54,11 @@ namespace OpenSim.Services.Connectors
55 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 54 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
56 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 55 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
57 56
57 public int MaxAssetRequestConcurrency
58 {
59 get { return m_maxAssetRequestConcurrency; }
60 set { m_maxAssetRequestConcurrency = value; }
61 }
58 62
59 public AssetServicesConnector() 63 public AssetServicesConnector()
60 { 64 {
@@ -66,6 +70,7 @@ namespace OpenSim.Services.Connectors
66 } 70 }
67 71
68 public AssetServicesConnector(IConfigSource source) 72 public AssetServicesConnector(IConfigSource source)
73 : base(source, "AssetService")
69 { 74 {
70 Initialise(source); 75 Initialise(source);
71 } 76 }
@@ -112,8 +117,16 @@ namespace OpenSim.Services.Connectors
112 117
113 if (asset == null) 118 if (asset == null)
114 { 119 {
115 asset = SynchronousRestObjectRequester. 120 // XXX: Commented out for now since this has either never been properly operational or not for some time
116 MakeRequest<int, AssetBase>("GET", uri, 0, m_maxAssetRequestConcurrency); 121 // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option.
122 // Wasn't noticed before because timeout wasn't actually used.
123 // Not attempting concurrency setting for now as this omission was discovered in release candidate
124 // phase for OpenSimulator 0.8. Need to revisit afterwards.
125// asset
126// = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>(
127// "GET", uri, 0, m_maxAssetRequestConcurrency);
128
129 asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth);
117 130
118 if (m_Cache != null) 131 if (m_Cache != null)
119 m_Cache.Cache(asset); 132 m_Cache.Cache(asset);
@@ -143,8 +156,7 @@ namespace OpenSim.Services.Connectors
143 156
144 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 157 string uri = m_ServerURI + "/assets/" + id + "/metadata";
145 158
146 AssetMetadata asset = SynchronousRestObjectRequester. 159 AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
147 MakeRequest<int, AssetMetadata>("GET", uri, 0);
148 return asset; 160 return asset;
149 } 161 }
150 162
@@ -158,27 +170,29 @@ namespace OpenSim.Services.Connectors
158 return fullAsset.Data; 170 return fullAsset.Data;
159 } 171 }
160 172
161 RestClient rc = new RestClient(m_ServerURI); 173 using (RestClient rc = new RestClient(m_ServerURI))
162 rc.AddResourcePath("assets"); 174 {
163 rc.AddResourcePath(id); 175 rc.AddResourcePath("assets");
164 rc.AddResourcePath("data"); 176 rc.AddResourcePath(id);
177 rc.AddResourcePath("data");
165 178
166 rc.RequestMethod = "GET"; 179 rc.RequestMethod = "GET";
167 180
168 Stream s = rc.Request(); 181 Stream s = rc.Request(m_Auth);
169 182
170 if (s == null) 183 if (s == null)
171 return null; 184 return null;
172 185
173 if (s.Length > 0) 186 if (s.Length > 0)
174 { 187 {
175 byte[] ret = new byte[s.Length]; 188 byte[] ret = new byte[s.Length];
176 s.Read(ret, 0, (int)s.Length); 189 s.Read(ret, 0, (int)s.Length);
177 190
178 return ret; 191 return ret;
179 } 192 }
180 193
181 return null; 194 return null;
195 }
182 } 196 }
183 197
184 public bool Get(string id, Object sender, AssetRetrieved handler) 198 public bool Get(string id, Object sender, AssetRetrieved handler)
@@ -216,7 +230,7 @@ namespace OpenSim.Services.Connectors
216 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 230 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0,
217 delegate(AssetBase a) 231 delegate(AssetBase a)
218 { 232 {
219 if (m_Cache != null) 233 if (a != null && m_Cache != null)
220 m_Cache.Cache(a); 234 m_Cache.Cache(a);
221 235
222 AssetRetrievedEx handlers; 236 AssetRetrievedEx handlers;
@@ -226,7 +240,7 @@ namespace OpenSim.Services.Connectors
226 m_AssetHandlers.Remove(id); 240 m_AssetHandlers.Remove(id);
227 } 241 }
228 handlers.Invoke(a); 242 handlers.Invoke(a);
229 }, m_maxAssetRequestConcurrency); 243 }, m_maxAssetRequestConcurrency, m_Auth);
230 244
231 success = true; 245 success = true;
232 } 246 }
@@ -249,9 +263,30 @@ namespace OpenSim.Services.Connectors
249 return true; 263 return true;
250 } 264 }
251 265
266 public virtual bool[] AssetsExist(string[] ids)
267 {
268 string uri = m_ServerURI + "/get_assets_exist";
269
270 bool[] exist = null;
271 try
272 {
273 exist = SynchronousRestObjectRequester.MakeRequest<string[], bool[]>("POST", uri, ids, m_Auth);
274 }
275 catch (Exception)
276 {
277 // This is most likely to happen because the server doesn't support this function,
278 // so just silently return "doesn't exist" for all the assets.
279 }
280
281 if (exist == null)
282 exist = new bool[ids.Length];
283
284 return exist;
285 }
286
252 public string Store(AssetBase asset) 287 public string Store(AssetBase asset)
253 { 288 {
254 if (asset.Temporary || asset.Local) 289 if (asset.Local)
255 { 290 {
256 if (m_Cache != null) 291 if (m_Cache != null)
257 m_Cache.Cache(asset); 292 m_Cache.Cache(asset);
@@ -261,27 +296,32 @@ namespace OpenSim.Services.Connectors
261 296
262 string uri = m_ServerURI + "/assets/"; 297 string uri = m_ServerURI + "/assets/";
263 298
264 string newID = string.Empty; 299 string newID;
265 try 300 try
266 { 301 {
267 newID = SynchronousRestObjectRequester. 302 newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, m_Auth);
268 MakeRequest<AssetBase, string>("POST", uri, asset);
269 } 303 }
270 catch (Exception e) 304 catch (Exception e)
271 { 305 {
272 m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message); 306 m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e);
307 return string.Empty;
273 } 308 }
274 309
275 if (newID != String.Empty) 310 // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets
311 if (newID == null)
276 { 312 {
277 // Placing this here, so that this work with old asset servers that don't send any reply back 313 m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID);
278 // SynchronousRestObjectRequester returns somethins that is not an empty string 314 return asset.ID;
279 if (newID != null)
280 asset.ID = newID;
281
282 if (m_Cache != null)
283 m_Cache.Cache(asset);
284 } 315 }
316
317 if (string.IsNullOrEmpty(newID))
318 return string.Empty;
319
320 asset.ID = newID;
321
322 if (m_Cache != null)
323 m_Cache.Cache(asset);
324
285 return newID; 325 return newID;
286 } 326 }
287 327
@@ -305,8 +345,7 @@ namespace OpenSim.Services.Connectors
305 345
306 string uri = m_ServerURI + "/assets/" + id; 346 string uri = m_ServerURI + "/assets/" + id;
307 347
308 if (SynchronousRestObjectRequester. 348 if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth))
309 MakeRequest<AssetBase, bool>("POST", uri, asset))
310 { 349 {
311 if (m_Cache != null) 350 if (m_Cache != null)
312 m_Cache.Cache(asset); 351 m_Cache.Cache(asset);
@@ -320,8 +359,7 @@ namespace OpenSim.Services.Connectors
320 { 359 {
321 string uri = m_ServerURI + "/assets/" + id; 360 string uri = m_ServerURI + "/assets/" + id;
322 361
323 if (SynchronousRestObjectRequester. 362 if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth))
324 MakeRequest<int, bool>("DELETE", uri, 0))
325 { 363 {
326 if (m_Cache != null) 364 if (m_Cache != null)
327 m_Cache.Expire(id); 365 m_Cache.Expire(id);
diff --git a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
index c395178..3710c86 100644
--- a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Services.Connectors.Hypergrid; 37using OpenSim.Services.Connectors.Hypergrid;
38using OpenSim.Services.Connectors.SimianGrid; 38using OpenSim.Services.Connectors.SimianGrid;
39using OpenMetaverse;
39 40
40namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.Connectors
41{ 42{
@@ -83,39 +84,6 @@ namespace OpenSim.Services.Connectors
83 } 84 }
84 } 85 }
85 86
86 private bool StringToUrlAndAssetID(string id, out string url, out string assetID)
87 {
88 url = String.Empty;
89 assetID = String.Empty;
90
91 Uri assetUri;
92
93 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
94 assetUri.Scheme == Uri.UriSchemeHttp)
95 {
96 // Simian
97 if (assetUri.Query != string.Empty)
98 {
99 NameValueCollection qscoll = HttpUtility.ParseQueryString(assetUri.Query);
100 assetID = qscoll["id"];
101 if (assetID != null)
102 url = id.Replace(assetID, ""); // Malformed again, as simian expects
103 else
104 url = id; // !!! best effort
105 }
106 else // robust
107 {
108 url = "http://" + assetUri.Authority;
109 assetID = assetUri.LocalPath.Trim(new char[] { '/' });
110 }
111
112 return true;
113 }
114
115 m_log.DebugFormat("[HG ASSET SERVICE]: Malformed URL {0}", id);
116 return false;
117 }
118
119 private IAssetService GetConnector(string url) 87 private IAssetService GetConnector(string url)
120 { 88 {
121 IAssetService connector = null; 89 IAssetService connector = null;
@@ -149,7 +117,7 @@ namespace OpenSim.Services.Connectors
149 string url = string.Empty; 117 string url = string.Empty;
150 string assetID = string.Empty; 118 string assetID = string.Empty;
151 119
152 if (StringToUrlAndAssetID(id, out url, out assetID)) 120 if (Util.ParseForeignAssetID(id, out url, out assetID))
153 { 121 {
154 IAssetService connector = GetConnector(url); 122 IAssetService connector = GetConnector(url);
155 return connector.Get(assetID); 123 return connector.Get(assetID);
@@ -163,7 +131,7 @@ namespace OpenSim.Services.Connectors
163 string url = string.Empty; 131 string url = string.Empty;
164 string assetID = string.Empty; 132 string assetID = string.Empty;
165 133
166 if (StringToUrlAndAssetID(id, out url, out assetID)) 134 if (Util.ParseForeignAssetID(id, out url, out assetID))
167 { 135 {
168 IAssetService connector = GetConnector(url); 136 IAssetService connector = GetConnector(url);
169 return connector.GetCached(assetID); 137 return connector.GetCached(assetID);
@@ -177,7 +145,7 @@ namespace OpenSim.Services.Connectors
177 string url = string.Empty; 145 string url = string.Empty;
178 string assetID = string.Empty; 146 string assetID = string.Empty;
179 147
180 if (StringToUrlAndAssetID(id, out url, out assetID)) 148 if (Util.ParseForeignAssetID(id, out url, out assetID))
181 { 149 {
182 IAssetService connector = GetConnector(url); 150 IAssetService connector = GetConnector(url);
183 return connector.GetMetadata(assetID); 151 return connector.GetMetadata(assetID);
@@ -196,7 +164,7 @@ namespace OpenSim.Services.Connectors
196 string url = string.Empty; 164 string url = string.Empty;
197 string assetID = string.Empty; 165 string assetID = string.Empty;
198 166
199 if (StringToUrlAndAssetID(id, out url, out assetID)) 167 if (Util.ParseForeignAssetID(id, out url, out assetID))
200 { 168 {
201 IAssetService connector = GetConnector(url); 169 IAssetService connector = GetConnector(url);
202 return connector.Get(assetID, sender, handler); 170 return connector.Get(assetID, sender, handler);
@@ -205,12 +173,72 @@ namespace OpenSim.Services.Connectors
205 return false; 173 return false;
206 } 174 }
207 175
176
177 private struct AssetAndIndex
178 {
179 public UUID assetID;
180 public int index;
181
182 public AssetAndIndex(UUID assetID, int index)
183 {
184 this.assetID = assetID;
185 this.index = index;
186 }
187 }
188
189 public virtual bool[] AssetsExist(string[] ids)
190 {
191 // This method is a bit complicated because it works even if the assets belong to different
192 // servers; that requires sending separate requests to each server.
193
194 // Group the assets by the server they belong to
195
196 var url2assets = new Dictionary<string, List<AssetAndIndex>>();
197
198 for (int i = 0; i < ids.Length; i++)
199 {
200 string url = string.Empty;
201 string assetID = string.Empty;
202
203 if (Util.ParseForeignAssetID(ids[i], out url, out assetID))
204 {
205 if (!url2assets.ContainsKey(url))
206 url2assets.Add(url, new List<AssetAndIndex>());
207 url2assets[url].Add(new AssetAndIndex(UUID.Parse(assetID), i));
208 }
209 }
210
211 // Query each of the servers in turn
212
213 bool[] exist = new bool[ids.Length];
214
215 foreach (string url in url2assets.Keys)
216 {
217 IAssetService connector = GetConnector(url);
218 lock (EndPointLock(connector))
219 {
220 List<AssetAndIndex> curAssets = url2assets[url];
221 string[] assetIDs = curAssets.ConvertAll(a => a.assetID.ToString()).ToArray();
222 bool[] curExist = connector.AssetsExist(assetIDs);
223
224 int i = 0;
225 foreach (AssetAndIndex ai in curAssets)
226 {
227 exist[ai.index] = curExist[i];
228 ++i;
229 }
230 }
231 }
232
233 return exist;
234 }
235
208 public string Store(AssetBase asset) 236 public string Store(AssetBase asset)
209 { 237 {
210 string url = string.Empty; 238 string url = string.Empty;
211 string assetID = string.Empty; 239 string assetID = string.Empty;
212 240
213 if (StringToUrlAndAssetID(asset.ID, out url, out assetID)) 241 if (Util.ParseForeignAssetID(asset.ID, out url, out assetID))
214 { 242 {
215 IAssetService connector = GetConnector(url); 243 IAssetService connector = GetConnector(url);
216 // Restore the assetID to a simple UUID 244 // Restore the assetID to a simple UUID
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
index 2b77154..c8a4912 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -32,14 +32,14 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenMetaverse; 38using OpenMetaverse;
39 39
40namespace OpenSim.Services.Connectors 40namespace OpenSim.Services.Connectors
41{ 41{
42 public class AuthenticationServicesConnector : IAuthenticationService 42 public class AuthenticationServicesConnector : BaseServiceConnector, IAuthenticationService
43 { 43 {
44 private static readonly ILog m_log = 44 private static readonly ILog m_log =
45 LogManager.GetLogger( 45 LogManager.GetLogger(
@@ -57,6 +57,7 @@ namespace OpenSim.Services.Connectors
57 } 57 }
58 58
59 public AuthenticationServicesConnector(IConfigSource source) 59 public AuthenticationServicesConnector(IConfigSource source)
60 : base(source, "AuthenticationService")
60 { 61 {
61 Initialise(source); 62 Initialise(source);
62 } 63 }
@@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors
79 throw new Exception("Authentication connector init error"); 80 throw new Exception("Authentication connector init error");
80 } 81 }
81 m_ServerURI = serviceURI; 82 m_ServerURI = serviceURI;
83
84 base.Initialise(source, "AuthenticationService");
82 } 85 }
83 86
84 public string Authenticate(UUID principalID, string password, int lifetime) 87 public string Authenticate(UUID principalID, string password, int lifetime)
@@ -92,7 +95,7 @@ namespace OpenSim.Services.Connectors
92 95
93 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 96 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
94 m_ServerURI + "/auth/plain", 97 m_ServerURI + "/auth/plain",
95 ServerUtils.BuildQueryString(sendData)); 98 ServerUtils.BuildQueryString(sendData), m_Auth);
96 99
97 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 100 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
98 reply); 101 reply);
@@ -105,6 +108,7 @@ namespace OpenSim.Services.Connectors
105 108
106 public bool Verify(UUID principalID, string token, int lifetime) 109 public bool Verify(UUID principalID, string token, int lifetime)
107 { 110 {
111// m_log.Error("[XXX]: Verify");
108 Dictionary<string, object> sendData = new Dictionary<string, object>(); 112 Dictionary<string, object> sendData = new Dictionary<string, object>();
109 sendData["LIFETIME"] = lifetime.ToString(); 113 sendData["LIFETIME"] = lifetime.ToString();
110 sendData["PRINCIPAL"] = principalID.ToString(); 114 sendData["PRINCIPAL"] = principalID.ToString();
@@ -114,7 +118,7 @@ namespace OpenSim.Services.Connectors
114 118
115 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 119 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
116 m_ServerURI + "/auth/plain", 120 m_ServerURI + "/auth/plain",
117 ServerUtils.BuildQueryString(sendData)); 121 ServerUtils.BuildQueryString(sendData), m_Auth);
118 122
119 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 123 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
120 reply); 124 reply);
@@ -135,7 +139,7 @@ namespace OpenSim.Services.Connectors
135 139
136 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 140 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
137 m_ServerURI + "/auth/plain", 141 m_ServerURI + "/auth/plain",
138 ServerUtils.BuildQueryString(sendData)); 142 ServerUtils.BuildQueryString(sendData), m_Auth);
139 143
140 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 144 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
141 reply); 145 reply);
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
index 35b7109..d2da85f 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs
@@ -32,7 +32,6 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
37using OpenMetaverse; 36using OpenMetaverse;
38 37
@@ -105,7 +104,7 @@ namespace OpenSim.Services.Connectors
105 catch (Exception e) 104 catch (Exception e)
106 { 105 {
107 m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message); 106 m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
108 message = ""; 107 message = e.Message;
109 return m_ResponseOnFailure; 108 return m_ResponseOnFailure;
110 } 109 }
111 if (response == null) 110 if (response == null)
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
index ddfca57..3f44efa 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs
@@ -32,7 +32,7 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using IAvatarService = OpenSim.Services.Interfaces.IAvatarService; 38using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
@@ -41,7 +41,7 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
43{ 43{
44 public class AvatarServicesConnector : IAvatarService 44 public class AvatarServicesConnector : BaseServiceConnector, IAvatarService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -59,6 +59,7 @@ namespace OpenSim.Services.Connectors
59 } 59 }
60 60
61 public AvatarServicesConnector(IConfigSource source) 61 public AvatarServicesConnector(IConfigSource source)
62 : base(source, "AvatarService")
62 { 63 {
63 Initialise(source); 64 Initialise(source);
64 } 65 }
@@ -81,6 +82,8 @@ namespace OpenSim.Services.Connectors
81 throw new Exception("Avatar connector init error"); 82 throw new Exception("Avatar connector init error");
82 } 83 }
83 m_ServerURI = serviceURI; 84 m_ServerURI = serviceURI;
85
86 base.Initialise(source, "AvatarService");
84 } 87 }
85 88
86 89
@@ -114,7 +117,7 @@ namespace OpenSim.Services.Connectors
114 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); 117 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
115 try 118 try
116 { 119 {
117 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 120 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
118 if (reply == null || (reply != null && reply == string.Empty)) 121 if (reply == null || (reply != null && reply == string.Empty))
119 { 122 {
120 m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply"); 123 m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply");
@@ -162,7 +165,7 @@ namespace OpenSim.Services.Connectors
162 //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); 165 //m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
163 try 166 try
164 { 167 {
165 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 168 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
166 if (reply != string.Empty) 169 if (reply != string.Empty)
167 { 170 {
168 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -207,7 +210,7 @@ namespace OpenSim.Services.Connectors
207 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); 210 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
208 try 211 try
209 { 212 {
210 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 213 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
211 if (reply != string.Empty) 214 if (reply != string.Empty)
212 { 215 {
213 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 216 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -250,7 +253,7 @@ namespace OpenSim.Services.Connectors
250 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); 253 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
251 try 254 try
252 { 255 {
253 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 256 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
254 if (reply != string.Empty) 257 if (reply != string.Empty)
255 { 258 {
256 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 259 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -293,7 +296,7 @@ namespace OpenSim.Services.Connectors
293 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); 296 // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString);
294 try 297 try
295 { 298 {
296 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 299 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
297 if (reply != string.Empty) 300 if (reply != string.Empty)
298 { 301 {
299 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 302 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
diff --git a/OpenSim/Services/Connectors/BaseServiceConnector.cs b/OpenSim/Services/Connectors/BaseServiceConnector.cs
new file mode 100644
index 0000000..98cd489
--- /dev/null
+++ b/OpenSim/Services/Connectors/BaseServiceConnector.cs
@@ -0,0 +1,33 @@
1using System;
2using OpenSim.Framework;
3using OpenSim.Framework.ServiceAuth;
4
5using Nini.Config;
6
7namespace OpenSim.Services.Connectors
8{
9 public class BaseServiceConnector
10 {
11 protected IServiceAuth m_Auth;
12
13 public BaseServiceConnector() { }
14
15 public BaseServiceConnector(IConfigSource config, string section)
16 {
17 Initialise(config, section);
18 }
19
20 public void Initialise(IConfigSource config, string section)
21 {
22 string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", section }, "None");
23
24 switch (authType)
25 {
26 case "BasicHttpAuthentication":
27 m_Auth = new BasicHttpAuthentication(config, section);
28 break;
29 }
30
31 }
32 }
33}
diff --git a/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
new file mode 100644
index 0000000..6412bcd
--- /dev/null
+++ b/OpenSim/Services/Connectors/Estate/EstateDataConnector.cs
@@ -0,0 +1,338 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Net;
30using System.Reflection;
31
32using log4net;
33
34using OpenMetaverse;
35using Nini.Config;
36
37using OpenSim.Framework;
38using OpenSim.Framework.ServiceAuth;
39using OpenSim.Services.Connectors;
40using OpenSim.Services.Interfaces;
41using OpenSim.Server.Base;
42
43namespace OpenSim.Services.Connectors
44{
45 public class EstateDataRemoteConnector : BaseServiceConnector, IEstateDataService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private string m_ServerURI = String.Empty;
52 private ExpiringCache<string, List<EstateSettings>> m_EstateCache = new ExpiringCache<string, List<EstateSettings>>();
53 private const int EXPIRATION = 5 * 60; // 5 minutes in secs
54
55 public EstateDataRemoteConnector(IConfigSource source)
56 {
57 Initialise(source);
58 }
59
60 public virtual void Initialise(IConfigSource source)
61 {
62 IConfig gridConfig = source.Configs["EstateService"];
63 if (gridConfig == null)
64 {
65 m_log.Error("[ESTATE CONNECTOR]: EstateService missing from OpenSim.ini");
66 throw new Exception("Estate connector init error");
67 }
68
69 string serviceURI = gridConfig.GetString("EstateServerURI",
70 String.Empty);
71
72 if (serviceURI == String.Empty)
73 {
74 m_log.Error("[ESTATE CONNECTOR]: No Server URI named in section EstateService");
75 throw new Exception("Estate connector init error");
76 }
77 m_ServerURI = serviceURI;
78
79 base.Initialise(source, "EstateService");
80 }
81
82 #region IEstateDataService
83
84 public List<EstateSettings> LoadEstateSettingsAll()
85 {
86 string reply = string.Empty;
87 string uri = m_ServerURI + "/estates";
88
89 reply = MakeRequest("GET", uri, string.Empty);
90 if (String.IsNullOrEmpty(reply))
91 return new List<EstateSettings>();
92
93 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
94
95 List<EstateSettings> estates = new List<EstateSettings>();
96 if (replyData != null && replyData.Count > 0)
97 {
98 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettingsAll returned {0} elements", replyData.Count);
99 Dictionary<string, object>.ValueCollection estateData = replyData.Values;
100 foreach (object r in estateData)
101 {
102 if (r is Dictionary<string, object>)
103 {
104 EstateSettings es = new EstateSettings((Dictionary<string, object>)r);
105 estates.Add(es);
106 }
107 }
108 m_EstateCache.AddOrUpdate("estates", estates, EXPIRATION);
109 }
110 else
111 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettingsAll from {0} received null or zero response", uri);
112
113 return estates;
114
115 }
116
117 public List<int> GetEstatesAll()
118 {
119 List<int> eids = new List<int>();
120 // If we don't have them, load them from the server
121 List<EstateSettings> estates = null;
122 if (!m_EstateCache.TryGetValue("estates", out estates))
123 LoadEstateSettingsAll();
124
125 foreach (EstateSettings es in estates)
126 eids.Add((int)es.EstateID);
127
128 return eids;
129 }
130
131 public List<int> GetEstates(string search)
132 {
133 // If we don't have them, load them from the server
134 List<EstateSettings> estates = null;
135 if (!m_EstateCache.TryGetValue("estates", out estates))
136 LoadEstateSettingsAll();
137
138 List<int> eids = new List<int>();
139 foreach (EstateSettings es in estates)
140 if (es.EstateName == search)
141 eids.Add((int)es.EstateID);
142
143 return eids;
144 }
145
146 public List<int> GetEstatesByOwner(UUID ownerID)
147 {
148 // If we don't have them, load them from the server
149 List<EstateSettings> estates = null;
150 if (!m_EstateCache.TryGetValue("estates", out estates))
151 LoadEstateSettingsAll();
152
153 List<int> eids = new List<int>();
154 foreach (EstateSettings es in estates)
155 if (es.EstateOwner == ownerID)
156 eids.Add((int)es.EstateID);
157
158 return eids;
159 }
160
161 public List<UUID> GetRegions(int estateID)
162 {
163 string reply = string.Empty;
164 // /estates/regions/?eid=int
165 string uri = m_ServerURI + "/estates/regions/?eid=" + estateID.ToString();
166
167 reply = MakeRequest("GET", uri, string.Empty);
168 if (String.IsNullOrEmpty(reply))
169 return new List<UUID>();
170
171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
172
173 List<UUID> regions = new List<UUID>();
174 if (replyData != null && replyData.Count > 0)
175 {
176 m_log.DebugFormat("[ESTATE CONNECTOR]: GetRegions for estate {0} returned {1} elements", estateID, replyData.Count);
177 Dictionary<string, object>.ValueCollection data = replyData.Values;
178 foreach (object r in data)
179 {
180 UUID uuid = UUID.Zero;
181 if (UUID.TryParse(r.ToString(), out uuid))
182 regions.Add(uuid);
183 }
184 }
185 else
186 m_log.DebugFormat("[ESTATE CONNECTOR]: GetRegions from {0} received null or zero response", uri);
187
188 return regions;
189 }
190
191 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
192 {
193 string reply = string.Empty;
194 // /estates/estate/?region=uuid&create=[t|f]
195 string uri = m_ServerURI + string.Format("/estates/estate/?region={0}&create={1}", regionID, create);
196
197 reply = MakeRequest("GET", uri, string.Empty);
198 if (String.IsNullOrEmpty(reply))
199 return null;
200
201 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
202
203 if (replyData != null && replyData.Count > 0)
204 {
205 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings({0}) returned {1} elements", regionID, replyData.Count);
206 EstateSettings es = new EstateSettings(replyData);
207 return es;
208 }
209 else
210 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings(regionID) from {0} received null or zero response", uri);
211
212 return null;
213 }
214
215 public EstateSettings LoadEstateSettings(int estateID)
216 {
217 string reply = string.Empty;
218 // /estates/estate/?eid=int
219 string uri = m_ServerURI + string.Format("/estates/estate/?eid={0}", estateID);
220
221 reply = MakeRequest("GET", uri, string.Empty);
222 if (String.IsNullOrEmpty(reply))
223 return null;
224
225 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
226
227 if (replyData != null && replyData.Count > 0)
228 {
229 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings({0}) returned {1} elements", estateID, replyData.Count);
230 EstateSettings es = new EstateSettings(replyData);
231 return es;
232 }
233 else
234 m_log.DebugFormat("[ESTATE CONNECTOR]: LoadEstateSettings(estateID) from {0} received null or zero response", uri);
235
236 return null;
237 }
238
239 /// <summary>
240 /// Forbidden operation
241 /// </summary>
242 /// <returns></returns>
243 public EstateSettings CreateNewEstate()
244 {
245 // No can do
246 return null;
247 }
248
249 public void StoreEstateSettings(EstateSettings es)
250 {
251 // /estates/estate/
252 string uri = m_ServerURI + ("/estates/estate");
253
254 Dictionary<string, object> formdata = es.ToMap();
255 formdata["OP"] = "STORE";
256
257 PostRequest(uri, formdata);
258 }
259
260 public bool LinkRegion(UUID regionID, int estateID)
261 {
262 // /estates/estate/?eid=int&region=uuid
263 string uri = m_ServerURI + String.Format("/estates/estate/?eid={0}&region={1}", estateID, regionID);
264
265 Dictionary<string, object> formdata = new Dictionary<string, object>();
266 formdata["OP"] = "LINK";
267 return PostRequest(uri, formdata);
268 }
269
270 private bool PostRequest(string uri, Dictionary<string, object> sendData)
271 {
272 string reqString = ServerUtils.BuildQueryString(sendData);
273
274 string reply = MakeRequest("POST", uri, reqString);
275 if (String.IsNullOrEmpty(reply))
276 return false;
277
278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
279
280 bool result = false;
281 if (replyData != null && replyData.Count > 0)
282 {
283 if (replyData.ContainsKey("Result"))
284 {
285 if (Boolean.TryParse(replyData["Result"].ToString(), out result))
286 m_log.DebugFormat("[ESTATE CONNECTOR]: PostRequest {0} returned {1}", uri, result);
287 }
288 }
289 else
290 m_log.DebugFormat("[ESTATE CONNECTOR]: PostRequest {0} received null or zero response", uri);
291
292 return result;
293 }
294
295 /// <summary>
296 /// Forbidden operation
297 /// </summary>
298 /// <returns></returns>
299 public bool DeleteEstate(int estateID)
300 {
301 return false;
302 }
303
304 #endregion
305
306 private string MakeRequest(string verb, string uri, string formdata)
307 {
308 string reply = string.Empty;
309 try
310 {
311 reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, m_Auth);
312 }
313 catch (WebException e)
314 {
315 using (HttpWebResponse hwr = (HttpWebResponse)e.Response)
316 {
317 if (hwr != null)
318 {
319 if (hwr.StatusCode == HttpStatusCode.NotFound)
320 m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri));
321 if (hwr.StatusCode == HttpStatusCode.Unauthorized)
322 m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri));
323 }
324 else
325 m_log.Error(string.Format(
326 "[ESTATE CONNECTOR]: WebException for {0} {1} {2} ",
327 verb, uri, formdata, e));
328 }
329 }
330 catch (Exception e)
331 {
332 m_log.DebugFormat("[ESTATE CONNECTOR]: Exception when contacting estate server at {0}: {1}", uri, e.Message);
333 }
334
335 return reply;
336 }
337 }
338}
diff --git a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
index d688299..20dc1cc 100644
--- a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
+++ b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
@@ -32,7 +32,7 @@ using System.Collections;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base; 37using OpenSim.Server.Base;
38using OpenMetaverse; 38using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
index b1dd84e..b7702a8 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.ServiceAuth;
36
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 38using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40 41
41namespace OpenSim.Services.Connectors.Friends 42namespace OpenSim.Services.Connectors.Friends
42{ 43{
43 public class FriendsServicesConnector : IFriendsService 44 public class FriendsServicesConnector : BaseServiceConnector, IFriendsService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors.Friends
80 throw new Exception("Friends connector init error"); 81 throw new Exception("Friends connector init error");
81 } 82 }
82 m_ServerURI = serviceURI; 83 m_ServerURI = serviceURI;
84 base.Initialise(source, "FriendsService");
83 } 85 }
84 86
85 87
@@ -112,7 +114,7 @@ namespace OpenSim.Services.Connectors.Friends
112 114
113 try 115 try
114 { 116 {
115 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 117 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
116 if (reply != string.Empty) 118 if (reply != string.Empty)
117 { 119 {
118 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 120 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -168,7 +170,7 @@ namespace OpenSim.Services.Connectors.Friends
168 string uri = m_ServerURI + "/friends"; 170 string uri = m_ServerURI + "/friends";
169 try 171 try
170 { 172 {
171 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); 173 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
172 } 174 }
173 catch (Exception e) 175 catch (Exception e)
174 { 176 {
@@ -223,7 +225,7 @@ namespace OpenSim.Services.Connectors.Friends
223 string uri = m_ServerURI + "/friends"; 225 string uri = m_ServerURI + "/friends";
224 try 226 try
225 { 227 {
226 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); 228 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
227 } 229 }
228 catch (Exception e) 230 catch (Exception e)
229 { 231 {
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 34ed0d7..596f867 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35
36using OpenSim.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40 41
41namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
42{ 43{
43 public class GridServicesConnector : IGridService 44 public class GridServicesConnector : BaseServiceConnector, IGridService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors
80 throw new Exception("Grid connector init error"); 81 throw new Exception("Grid connector init error");
81 } 82 }
82 m_ServerURI = serviceURI; 83 m_ServerURI = serviceURI;
84
85 base.Initialise(source, "GridService");
83 } 86 }
84 87
85 88
@@ -102,7 +105,7 @@ namespace OpenSim.Services.Connectors
102 // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); 105 // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
103 try 106 try
104 { 107 {
105 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 108 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
106 if (reply != string.Empty) 109 if (reply != string.Empty)
107 { 110 {
108 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 111 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -158,7 +161,7 @@ namespace OpenSim.Services.Connectors
158 try 161 try
159 { 162 {
160 string reply 163 string reply
161 = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); 164 = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
162 165
163 if (reply != string.Empty) 166 if (reply != string.Empty)
164 { 167 {
@@ -195,7 +198,7 @@ namespace OpenSim.Services.Connectors
195 198
196 try 199 try
197 { 200 {
198 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); 201 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth);
199 } 202 }
200 catch (Exception e) 203 catch (Exception e)
201 { 204 {
@@ -238,7 +241,7 @@ namespace OpenSim.Services.Connectors
238 string uri = m_ServerURI + "/grid"; 241 string uri = m_ServerURI + "/grid";
239 try 242 try
240 { 243 {
241 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData)); 244 reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth);
242 } 245 }
243 catch (Exception e) 246 catch (Exception e)
244 { 247 {
@@ -285,7 +288,7 @@ namespace OpenSim.Services.Connectors
285 { 288 {
286 reply = SynchronousRestFormsRequester.MakeRequest("POST", 289 reply = SynchronousRestFormsRequester.MakeRequest("POST",
287 uri, 290 uri,
288 ServerUtils.BuildQueryString(sendData)); 291 ServerUtils.BuildQueryString(sendData), m_Auth);
289 } 292 }
290 catch (Exception e) 293 catch (Exception e)
291 { 294 {
@@ -330,7 +333,7 @@ namespace OpenSim.Services.Connectors
330 { 333 {
331 reply = SynchronousRestFormsRequester.MakeRequest("POST", 334 reply = SynchronousRestFormsRequester.MakeRequest("POST",
332 uri, 335 uri,
333 ServerUtils.BuildQueryString(sendData)); 336 ServerUtils.BuildQueryString(sendData), m_Auth);
334 } 337 }
335 catch (Exception e) 338 catch (Exception e)
336 { 339 {
@@ -374,7 +377,7 @@ namespace OpenSim.Services.Connectors
374 { 377 {
375 reply = SynchronousRestFormsRequester.MakeRequest("POST", 378 reply = SynchronousRestFormsRequester.MakeRequest("POST",
376 uri, 379 uri,
377 ServerUtils.BuildQueryString(sendData)); 380 ServerUtils.BuildQueryString(sendData), m_Auth);
378 } 381 }
379 catch (Exception e) 382 catch (Exception e)
380 { 383 {
@@ -428,7 +431,7 @@ namespace OpenSim.Services.Connectors
428 { 431 {
429 reply = SynchronousRestFormsRequester.MakeRequest("POST", 432 reply = SynchronousRestFormsRequester.MakeRequest("POST",
430 uri, 433 uri,
431 ServerUtils.BuildQueryString(sendData)); 434 ServerUtils.BuildQueryString(sendData), m_Auth);
432 435
433 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); 436 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
434 } 437 }
@@ -479,7 +482,7 @@ namespace OpenSim.Services.Connectors
479 { 482 {
480 reply = SynchronousRestFormsRequester.MakeRequest("POST", 483 reply = SynchronousRestFormsRequester.MakeRequest("POST",
481 uri, 484 uri,
482 ServerUtils.BuildQueryString(sendData)); 485 ServerUtils.BuildQueryString(sendData), m_Auth);
483 486
484 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); 487 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
485 } 488 }
@@ -515,6 +518,57 @@ namespace OpenSim.Services.Connectors
515 return rinfos; 518 return rinfos;
516 } 519 }
517 520
521 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
522 {
523 Dictionary<string, object> sendData = new Dictionary<string, object>();
524
525 sendData["SCOPEID"] = scopeID.ToString();
526
527 sendData["METHOD"] = "get_default_hypergrid_regions";
528
529 List<GridRegion> rinfos = new List<GridRegion>();
530 string reply = string.Empty;
531 string uri = m_ServerURI + "/grid";
532 try
533 {
534 reply = SynchronousRestFormsRequester.MakeRequest("POST",
535 uri,
536 ServerUtils.BuildQueryString(sendData), m_Auth);
537
538 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
539 }
540 catch (Exception e)
541 {
542 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
543 return rinfos;
544 }
545
546 if (reply != string.Empty)
547 {
548 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
549
550 if (replyData != null)
551 {
552 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
553 foreach (object r in rinfosList)
554 {
555 if (r is Dictionary<string, object>)
556 {
557 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
558 rinfos.Add(rinfo);
559 }
560 }
561 }
562 else
563 m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response",
564 scopeID);
565 }
566 else
567 m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply");
568
569 return rinfos;
570 }
571
518 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 572 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
519 { 573 {
520 Dictionary<string, object> sendData = new Dictionary<string, object>(); 574 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -532,7 +586,7 @@ namespace OpenSim.Services.Connectors
532 { 586 {
533 reply = SynchronousRestFormsRequester.MakeRequest("POST", 587 reply = SynchronousRestFormsRequester.MakeRequest("POST",
534 uri, 588 uri,
535 ServerUtils.BuildQueryString(sendData)); 589 ServerUtils.BuildQueryString(sendData), m_Auth);
536 590
537 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); 591 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
538 } 592 }
@@ -583,7 +637,7 @@ namespace OpenSim.Services.Connectors
583 { 637 {
584 reply = SynchronousRestFormsRequester.MakeRequest("POST", 638 reply = SynchronousRestFormsRequester.MakeRequest("POST",
585 uri, 639 uri,
586 ServerUtils.BuildQueryString(sendData)); 640 ServerUtils.BuildQueryString(sendData), m_Auth);
587 641
588 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); 642 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
589 } 643 }
@@ -634,7 +688,7 @@ namespace OpenSim.Services.Connectors
634 { 688 {
635 reply = SynchronousRestFormsRequester.MakeRequest("POST", 689 reply = SynchronousRestFormsRequester.MakeRequest("POST",
636 uri, 690 uri,
637 ServerUtils.BuildQueryString(sendData)); 691 ServerUtils.BuildQueryString(sendData), m_Auth);
638 } 692 }
639 catch (Exception e) 693 catch (Exception e)
640 { 694 {
@@ -665,6 +719,45 @@ namespace OpenSim.Services.Connectors
665 return flags; 719 return flags;
666 } 720 }
667 721
722 public Dictionary<string, object> GetExtraFeatures()
723 {
724 Dictionary<string, object> sendData = new Dictionary<string, object>();
725 Dictionary<string, object> extraFeatures = new Dictionary<string, object>();
726
727 sendData["METHOD"] = "get_grid_extra_features";
728
729 string reply = string.Empty;
730 string uri = m_ServerURI + "/grid";
731
732 try
733 {
734 reply = SynchronousRestFormsRequester.MakeRequest("POST",
735 uri,
736 ServerUtils.BuildQueryString(sendData), m_Auth);
737 }
738 catch (Exception e)
739 {
740 m_log.DebugFormat("[GRID CONNECTOR]: GetExtraFeatures - Exception when contacting grid server at {0}: {1}", uri, e.Message);
741 return extraFeatures;
742 }
743
744 if (reply != string.Empty)
745 {
746 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
747
748 if ((replyData != null) && replyData.Count > 0)
749 {
750 foreach (string key in replyData.Keys)
751 {
752 extraFeatures[key] = replyData[key].ToString();
753 }
754 }
755 }
756 else
757 m_log.DebugFormat("[GRID CONNECTOR]: GetExtraServiceURLs received null reply");
758
759 return extraFeatures;
760 }
668 #endregion 761 #endregion
669 762
670 } 763 }
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
index 94bda82..b5ca1ad 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35
36using OpenSim.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40 41
41namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
42{ 43{
43 public class GridUserServicesConnector : IGridUserService 44 public class GridUserServicesConnector : BaseServiceConnector, IGridUserService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -80,6 +81,7 @@ namespace OpenSim.Services.Connectors
80 throw new Exception("GridUser connector init error"); 81 throw new Exception("GridUser connector init error");
81 } 82 }
82 m_ServerURI = serviceURI; 83 m_ServerURI = serviceURI;
84 base.Initialise(source, "GridUserService");
83 } 85 }
84 86
85 87
@@ -162,7 +164,8 @@ namespace OpenSim.Services.Connectors
162 { 164 {
163 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 165 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
164 uri, 166 uri,
165 reqString); 167 reqString,
168 m_Auth);
166 if (reply != string.Empty) 169 if (reply != string.Empty)
167 { 170 {
168 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -198,7 +201,8 @@ namespace OpenSim.Services.Connectors
198 { 201 {
199 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 202 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
200 uri, 203 uri,
201 reqString); 204 reqString,
205 m_Auth);
202 if (reply != string.Empty) 206 if (reply != string.Empty)
203 { 207 {
204 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 208 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -214,7 +218,7 @@ namespace OpenSim.Services.Connectors
214 218
215 } 219 }
216 else 220 else
217 m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply"); 221 m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply");
218 } 222 }
219 catch (Exception e) 223 catch (Exception e)
220 { 224 {
@@ -243,7 +247,8 @@ namespace OpenSim.Services.Connectors
243 { 247 {
244 reply = SynchronousRestFormsRequester.MakeRequest("POST", 248 reply = SynchronousRestFormsRequester.MakeRequest("POST",
245 uri, 249 uri,
246 reqString); 250 reqString,
251 m_Auth);
247 if (reply == null || (reply != null && reply == string.Empty)) 252 if (reply == null || (reply != null && reply == string.Empty))
248 { 253 {
249 m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply"); 254 m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply");
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 5bcff48..b1663ee 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
53 53
54 private IAssetService m_AssetService; 54 private IAssetService m_AssetService;
55 55
56 public GatekeeperServiceConnector() : base() 56 public GatekeeperServiceConnector()
57 : base()
57 { 58 {
58 } 59 }
59 60
@@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
123 realHandle = Convert.ToUInt64((string)hash["handle"]); 124 realHandle = Convert.ToUInt64((string)hash["handle"]);
124 //m_log.Debug(">> HERE, realHandle: " + realHandle); 125 //m_log.Debug(">> HERE, realHandle: " + realHandle);
125 } 126 }
126 if (hash["region_image"] != null) { 127 if (hash["region_image"] != null)
128 {
127 imageURL = (string)hash["region_image"]; 129 imageURL = (string)hash["region_image"];
128 //m_log.Debug(">> HERE, imageURL: " + imageURL); 130 //m_log.Debug(">> HERE, imageURL: " + imageURL);
129 } 131 }
130 if (hash["external_name"] != null) { 132 if (hash["external_name"] != null)
133 {
131 externalName = (string)hash["external_name"]; 134 externalName = (string)hash["external_name"];
132 //m_log.Debug(">> HERE, externalName: " + externalName); 135 //m_log.Debug(">> HERE, externalName: " + externalName);
133 } 136 }
@@ -178,7 +181,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
178 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 181 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
179 imageData = OpenJPEG.EncodeFromImage(bitmap, true); 182 imageData = OpenJPEG.EncodeFromImage(bitmap, true);
180 } 183 }
181 184
182 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); 185 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
183 186
184 // !!! for now 187 // !!! for now
@@ -199,10 +202,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
199 return mapTile; 202 return mapTile;
200 } 203 }
201 204
202 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) 205 public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID agentID, string agentHomeURI, out string message)
203 { 206 {
204 Hashtable hash = new Hashtable(); 207 Hashtable hash = new Hashtable();
205 hash["region_uuid"] = regionID.ToString(); 208 hash["region_uuid"] = regionID.ToString();
209 if (agentID != UUID.Zero)
210 {
211 hash["agent_id"] = agentID.ToString();
212 if (agentHomeURI != null)
213 hash["agent_home_uri"] = agentHomeURI;
214 }
206 215
207 IList paramList = new ArrayList(); 216 IList paramList = new ArrayList();
208 paramList.Add(hash); 217 paramList.Add(hash);
@@ -216,12 +225,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
216 } 225 }
217 catch (Exception e) 226 catch (Exception e)
218 { 227 {
228 message = "Error contacting grid.";
219 m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); 229 m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message);
220 return null; 230 return null;
221 } 231 }
222 232
223 if (response.IsFault) 233 if (response.IsFault)
224 { 234 {
235 message = "Error contacting grid.";
225 m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); 236 m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString);
226 return null; 237 return null;
227 } 238 }
@@ -233,6 +244,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
233 { 244 {
234 bool success = false; 245 bool success = false;
235 Boolean.TryParse((string)hash["result"], out success); 246 Boolean.TryParse((string)hash["result"], out success);
247
248 if (hash["message"] != null)
249 message = (string)hash["message"];
250 else if (success)
251 message = null;
252 else
253 message = "The teleport destination could not be found."; // probably the dest grid is old and doesn't send 'message', but the most common problem is that the region is unavailable
254
236 if (success) 255 if (success)
237 { 256 {
238 GridRegion region = new GridRegion(); 257 GridRegion region = new GridRegion();
@@ -252,12 +271,25 @@ namespace OpenSim.Services.Connectors.Hypergrid
252 region.RegionLocY = n; 271 region.RegionLocY = n;
253 //m_log.Debug(">> HERE, y: " + region.RegionLocY); 272 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
254 } 273 }
274 if (hash["size_x"] != null)
275 {
276 Int32.TryParse((string)hash["size_x"], out n);
277 region.RegionSizeX = n;
278 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
279 }
280 if (hash["size_y"] != null)
281 {
282 Int32.TryParse((string)hash["size_y"], out n);
283 region.RegionSizeY = n;
284 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
285 }
255 if (hash["region_name"] != null) 286 if (hash["region_name"] != null)
256 { 287 {
257 region.RegionName = (string)hash["region_name"]; 288 region.RegionName = (string)hash["region_name"];
258 //m_log.Debug(">> HERE, region_name: " + region.RegionName); 289 //m_log.Debug(">> HERE, region_name: " + region.RegionName);
259 } 290 }
260 if (hash["hostname"] != null) { 291 if (hash["hostname"] != null)
292 {
261 region.ExternalHostName = (string)hash["hostname"]; 293 region.ExternalHostName = (string)hash["hostname"];
262 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); 294 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName);
263 } 295 }
@@ -275,10 +307,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
275 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); 307 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
276 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); 308 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint);
277 } 309 }
278 310
279 if (hash["server_uri"] != null) 311 if (hash["server_uri"] != null)
280 { 312 {
281 region.ServerURI = (string) hash["server_uri"]; 313 region.ServerURI = (string)hash["server_uri"];
282 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); 314 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI);
283 } 315 }
284 316
@@ -289,61 +321,12 @@ namespace OpenSim.Services.Connectors.Hypergrid
289 } 321 }
290 catch (Exception e) 322 catch (Exception e)
291 { 323 {
324 message = "Error parsing response from grid.";
292 m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); 325 m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace);
293 return null; 326 return null;
294 } 327 }
295 328
296 return null; 329 return null;
297 } 330 }
298
299 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
300 {
301 // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");
302
303 myipaddress = String.Empty;
304 reason = String.Empty;
305
306 if (destination == null)
307 {
308 m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
309 return false;
310 }
311
312 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
313
314 try
315 {
316 OSDMap args = aCircuit.PackAgentCircuitData();
317
318 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
319 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
320 args["destination_name"] = OSD.FromString(destination.RegionName);
321 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
322 args["teleport_flags"] = OSD.FromString(flags.ToString());
323
324 OSDMap result = WebUtil.PostToService(uri, args, 80000);
325 if (result["Success"].AsBoolean())
326 {
327 OSDMap unpacked = (OSDMap)result["_Result"];
328
329 if (unpacked != null)
330 {
331 reason = unpacked["reason"].AsString();
332 myipaddress = unpacked["your_ip"].AsString();
333 return unpacked["success"].AsBoolean();
334 }
335 }
336
337 reason = result["Message"] != null ? result["Message"].AsString() : "error";
338 return false;
339 }
340 catch (Exception e)
341 {
342 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
343 reason = e.Message;
344 }
345
346 return false;
347 }
348 } 331 }
349} 332}
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
index e984a54..622d4e1 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs
@@ -277,7 +277,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
277 { 277 {
278 reply = SynchronousRestFormsRequester.MakeRequest("POST", 278 reply = SynchronousRestFormsRequester.MakeRequest("POST",
279 uri, 279 uri,
280 ServerUtils.BuildQueryString(sendData)); 280 ServerUtils.BuildQueryString(sendData), 15);
281 } 281 }
282 catch (Exception e) 282 catch (Exception e)
283 { 283 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
index 5c50936..b5e6d69 100644
--- a/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs
@@ -47,16 +47,22 @@ namespace OpenSim.Services.Connectors
47 47
48 public HeloServicesConnector(string serverURI) 48 public HeloServicesConnector(string serverURI)
49 { 49 {
50 if (!serverURI.EndsWith("=")) 50 try
51 m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
52 else
53 { 51 {
54 // Simian sends malformed urls like this: 52 Uri uri;
55 // http://valley.virtualportland.org/simtest/Grid/?id= 53
56 // 54 if (!serverURI.EndsWith("="))
57 try 55 {
56 // Let's check if this is a valid URI, because it may not be
57 uri = new Uri(serverURI);
58 m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
59 }
60 else
58 { 61 {
59 Uri uri = new Uri(serverURI + "xxx"); 62 // Simian sends malformed urls like this:
63 // http://valley.virtualportland.org/simtest/Grid/?id=
64 //
65 uri = new Uri(serverURI + "xxx");
60 if (uri.Query == string.Empty) 66 if (uri.Query == string.Empty)
61 m_ServerURI = serverURI.TrimEnd('/') + "/helo/"; 67 m_ServerURI = serverURI.TrimEnd('/') + "/helo/";
62 else 68 else
@@ -66,26 +72,34 @@ namespace OpenSim.Services.Connectors
66 m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; 72 m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/";
67 } 73 }
68 } 74 }
69 catch (UriFormatException) 75
70 { 76 }
71 m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); 77 catch (UriFormatException)
72 } 78 {
79 m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI);
73 } 80 }
74 } 81 }
75 82
76
77 public virtual string Helo() 83 public virtual string Helo()
78 { 84 {
79 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); 85 if (String.IsNullOrEmpty(m_ServerURI))
80 // Eventually we need to switch to HEAD 86 {
81 /* req.Method = "HEAD"; */ 87 m_log.WarnFormat("[HELO SERVICE]: Unable to invoke HELO due to empty URL");
88 return String.Empty;
89 }
82 90
83 try 91 try
84 { 92 {
85 WebResponse response = req.GetResponse(); 93 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
86 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null 94 // Eventually we need to switch to HEAD
87 return string.Empty; 95 /* req.Method = "HEAD"; */
88 return response.Headers.Get("X-Handlers-Provided"); 96
97 using (WebResponse response = req.GetResponse())
98 {
99 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
100 return string.Empty;
101 return response.Headers.Get("X-Handlers-Provided");
102 }
89 } 103 }
90 catch (Exception e) 104 catch (Exception e)
91 { 105 {
@@ -95,6 +109,5 @@ namespace OpenSim.Services.Connectors
95 // fail 109 // fail
96 return string.Empty; 110 return string.Empty;
97 } 111 }
98
99 } 112 }
100} 113} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 2f263ae..8abd046 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -44,13 +44,15 @@ using Nini.Config;
44 44
45namespace OpenSim.Services.Connectors.Hypergrid 45namespace OpenSim.Services.Connectors.Hypergrid
46{ 46{
47 public class UserAgentServiceConnector : IUserAgentService 47 public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService
48 { 48 {
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger( 50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 string m_ServerURL; 53 private string m_ServerURLHost;
54 private string m_ServerURL;
55 private GridRegion m_Gatekeeper;
54 56
55 public UserAgentServiceConnector(string url) : this(url, true) 57 public UserAgentServiceConnector(string url) : this(url, true)
56 { 58 {
@@ -58,7 +60,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
58 60
59 public UserAgentServiceConnector(string url, bool dnsLookup) 61 public UserAgentServiceConnector(string url, bool dnsLookup)
60 { 62 {
61 m_ServerURL = url; 63 m_ServerURL = m_ServerURLHost = url;
62 64
63 if (dnsLookup) 65 if (dnsLookup)
64 { 66 {
@@ -74,10 +76,11 @@ namespace OpenSim.Services.Connectors.Hypergrid
74 } 76 }
75 catch (Exception e) 77 catch (Exception e)
76 { 78 {
77 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); 79 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message);
78 } 80 }
79 } 81 }
80 m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); 82
83 //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
81 } 84 }
82 85
83 public UserAgentServiceConnector(IConfigSource config) 86 public UserAgentServiceConnector(IConfigSource config)
@@ -97,16 +100,23 @@ namespace OpenSim.Services.Connectors.Hypergrid
97 m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService"); 100 m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
98 throw new Exception("UserAgent connector init error"); 101 throw new Exception("UserAgent connector init error");
99 } 102 }
100 m_ServerURL = serviceURI; 103
104 m_ServerURL = m_ServerURLHost = serviceURI;
101 if (!m_ServerURL.EndsWith("/")) 105 if (!m_ServerURL.EndsWith("/"))
102 m_ServerURL += "/"; 106 m_ServerURL += "/";
103 107
104 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 108 //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0}", m_ServerURL);
105 } 109 }
106 110
111 protected override string AgentPath()
112 {
113 return "homeagent/";
114 }
107 115
108 // The Login service calls this interface with a non-null [client] ipaddress 116 // The Login service calls this interface with fromLogin=true
109 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) 117 // Sims call it with fromLogin=false
118 // Either way, this is verified by the handler
119 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
110 { 120 {
111 reason = String.Empty; 121 reason = String.Empty;
112 122
@@ -117,151 +127,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
117 return false; 127 return false;
118 } 128 }
119 129
120 string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/"; 130 GridRegion home = new GridRegion();
121 131 home.ServerURI = m_ServerURL;
122 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); 132 home.RegionID = destination.RegionID;
123 133 home.RegionLocX = destination.RegionLocX;
124 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); 134 home.RegionLocY = destination.RegionLocY;
125 AgentCreateRequest.Method = "POST";
126 AgentCreateRequest.ContentType = "application/json";
127 AgentCreateRequest.Timeout = 10000;
128 //AgentCreateRequest.KeepAlive = false;
129 //AgentCreateRequest.Headers.Add("Authorization", authKey);
130
131 // Fill it in
132 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
133
134 string strBuffer = "";
135 byte[] buffer = new byte[1];
136 try
137 {
138 strBuffer = OSDParser.SerializeJsonString(args);
139 Encoding str = Util.UTF8;
140 buffer = str.GetBytes(strBuffer);
141
142 }
143 catch (Exception e)
144 {
145 m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
146 // ignore. buffer will be empty, caller should check.
147 }
148
149 Stream os = null;
150 try
151 { // send the Post
152 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
153 os = AgentCreateRequest.GetRequestStream();
154 os.Write(buffer, 0, strBuffer.Length); //Send it
155 m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
156 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
157 }
158 //catch (WebException ex)
159 catch
160 {
161 //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
162 reason = "cannot contact remote region";
163 return false;
164 }
165 finally
166 {
167 if (os != null)
168 os.Close();
169 }
170
171 // Let's wait for the response
172 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
173 135
174 WebResponse webResponse = null; 136 m_Gatekeeper = gatekeeper;
175 StreamReader sr = null;
176 try
177 {
178 webResponse = AgentCreateRequest.GetResponse();
179 if (webResponse == null)
180 {
181 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
182 }
183 else
184 {
185 137
186 sr = new StreamReader(webResponse.GetResponseStream()); 138 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
187 string response = sr.ReadToEnd().Trim();
188 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
189
190 if (!String.IsNullOrEmpty(response))
191 {
192 try
193 {
194 // we assume we got an OSDMap back
195 OSDMap r = Util.GetOSDMap(response);
196 bool success = r["success"].AsBoolean();
197 reason = r["reason"].AsString();
198 return success;
199 }
200 catch (NullReferenceException e)
201 {
202 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
203
204 // check for old style response
205 if (response.ToLower().StartsWith("true"))
206 return true;
207
208 return false;
209 }
210 }
211 }
212 }
213 catch (WebException ex)
214 {
215 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
216 reason = "Destination did not reply";
217 return false;
218 }
219 finally
220 {
221 if (sr != null)
222 sr.Close();
223 }
224
225 return true;
226 139
140 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
141 return CreateAgent(source, home, aCircuit, flags, out reason);
227 } 142 }
228 143
229 144
230 // The simulators call this interface 145 // The simulators call this interface
231 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) 146 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
232 { 147 {
233 return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); 148 return LoginAgentToGrid(source, aCircuit, gatekeeper, destination, false, out reason);
234 } 149 }
235 150
236 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) 151 protected override void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags)
237 { 152 {
238 OSDMap args = null; 153 base.PackData(args, source, aCircuit, destination, flags);
239 try 154 args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
240 { 155 args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
241 args = aCircuit.PackAgentCircuitData(); 156 args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
242 }
243 catch (Exception e)
244 {
245 m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
246 }
247
248 // Add the input arguments
249 args["gatekeeper_serveruri"] = OSD.FromString(gatekeeper.ServerURI);
250 args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName);
251 args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString());
252 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
253 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
254 args["destination_name"] = OSD.FromString(destination.RegionName);
255 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
256 args["destination_serveruri"] = OSD.FromString(destination.ServerURI); 157 args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
257
258 // 10/3/2010
259 // I added the client_ip up to the regular AgentCircuitData, so this doesn't need to be here.
260 // This need cleaning elsewhere...
261 //if (ipaddress != null)
262 // args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
263
264 return args;
265 } 158 }
266 159
267 public void SetClientToken(UUID sessionID, string token) 160 public void SetClientToken(UUID sessionID, string token)
@@ -269,96 +162,111 @@ namespace OpenSim.Services.Connectors.Hypergrid
269 // no-op 162 // no-op
270 } 163 }
271 164
272 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) 165 private Hashtable CallServer(string methodName, Hashtable hash)
273 { 166 {
274 position = Vector3.UnitY; lookAt = Vector3.UnitY;
275
276 Hashtable hash = new Hashtable();
277 hash["userID"] = userID.ToString();
278
279 IList paramList = new ArrayList(); 167 IList paramList = new ArrayList();
280 paramList.Add(hash); 168 paramList.Add(hash);
281 169
282 XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); 170 XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
171
172 // Send and get reply
283 XmlRpcResponse response = null; 173 XmlRpcResponse response = null;
284 try 174 try
285 { 175 {
286 response = request.Send(m_ServerURL, 10000); 176 response = request.Send(m_ServerURL, 10000);
287 } 177 }
288 catch (Exception) 178 catch (Exception e)
289 { 179 {
290 return null; 180 m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message);
181 throw;
291 } 182 }
292 183
293 if (response.IsFault) 184 if (response.IsFault)
294 { 185 {
295 return null; 186 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString));
296 } 187 }
297 188
298 hash = (Hashtable)response.Value; 189 hash = (Hashtable)response.Value;
299 //foreach (Object o in hash) 190
300 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); 191 if (hash == null)
301 try
302 { 192 {
303 bool success = false; 193 throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost));
304 Boolean.TryParse((string)hash["result"], out success); 194 }
305 if (success)
306 {
307 GridRegion region = new GridRegion();
308 195
309 UUID.TryParse((string)hash["uuid"], out region.RegionID); 196 return hash;
310 //m_log.Debug(">> HERE, uuid: " + region.RegionID); 197 }
311 int n = 0;
312 if (hash["x"] != null)
313 {
314 Int32.TryParse((string)hash["x"], out n);
315 region.RegionLocX = n;
316 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
317 }
318 if (hash["y"] != null)
319 {
320 Int32.TryParse((string)hash["y"], out n);
321 region.RegionLocY = n;
322 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
323 }
324 if (hash["region_name"] != null)
325 {
326 region.RegionName = (string)hash["region_name"];
327 //m_log.Debug(">> HERE, name: " + region.RegionName);
328 }
329 if (hash["hostname"] != null)
330 region.ExternalHostName = (string)hash["hostname"];
331 if (hash["http_port"] != null)
332 {
333 uint p = 0;
334 UInt32.TryParse((string)hash["http_port"], out p);
335 region.HttpPort = p;
336 }
337 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
338 region.ServerURI = (string)hash["server_uri"];
339 198
340 if (hash["internal_port"] != null) 199 public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt)
341 { 200 {
342 int p = 0; 201 position = Vector3.UnitY; lookAt = Vector3.UnitY;
343 Int32.TryParse((string)hash["internal_port"], out p);
344 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
345 }
346 if (hash["position"] != null)
347 Vector3.TryParse((string)hash["position"], out position);
348 if (hash["lookAt"] != null)
349 Vector3.TryParse((string)hash["lookAt"], out lookAt);
350 202
351 // Successful return 203 Hashtable hash = new Hashtable();
352 return region; 204 hash["userID"] = userID.ToString();
353 } 205
206 hash = CallServer("get_home_region", hash);
207
208 bool success;
209 if (!Boolean.TryParse((string)hash["result"], out success) || !success)
210 return null;
211
212 GridRegion region = new GridRegion();
354 213
214 UUID.TryParse((string)hash["uuid"], out region.RegionID);
215 //m_log.Debug(">> HERE, uuid: " + region.RegionID);
216 int n = 0;
217 if (hash["x"] != null)
218 {
219 Int32.TryParse((string)hash["x"], out n);
220 region.RegionLocX = n;
221 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
355 } 222 }
356 catch (Exception) 223 if (hash["y"] != null)
357 { 224 {
358 return null; 225 Int32.TryParse((string)hash["y"], out n);
226 region.RegionLocY = n;
227 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
228 }
229 if (hash["size_x"] != null)
230 {
231 Int32.TryParse((string)hash["size_x"], out n);
232 region.RegionSizeX = n;
233 //m_log.Debug(">> HERE, x: " + region.RegionLocX);
359 } 234 }
235 if (hash["size_y"] != null)
236 {
237 Int32.TryParse((string)hash["size_y"], out n);
238 region.RegionSizeY = n;
239 //m_log.Debug(">> HERE, y: " + region.RegionLocY);
240 }
241 if (hash["region_name"] != null)
242 {
243 region.RegionName = (string)hash["region_name"];
244 //m_log.Debug(">> HERE, name: " + region.RegionName);
245 }
246 if (hash["hostname"] != null)
247 region.ExternalHostName = (string)hash["hostname"];
248 if (hash["http_port"] != null)
249 {
250 uint p = 0;
251 UInt32.TryParse((string)hash["http_port"], out p);
252 region.HttpPort = p;
253 }
254 if (hash.ContainsKey("server_uri") && hash["server_uri"] != null)
255 region.ServerURI = (string)hash["server_uri"];
360 256
361 return null; 257 if (hash["internal_port"] != null)
258 {
259 int p = 0;
260 Int32.TryParse((string)hash["internal_port"], out p);
261 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
262 }
263 if (hash["position"] != null)
264 Vector3.TryParse((string)hash["position"], out position);
265 if (hash["lookAt"] != null)
266 Vector3.TryParse((string)hash["lookAt"], out lookAt);
267
268 // Successful return
269 return region;
362 } 270 }
363 271
364 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 272 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
@@ -445,14 +353,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
445 } 353 }
446 catch 354 catch
447 { 355 {
448 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURL); 356 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURLHost);
449// reason = "Exception: " + e.Message; 357// reason = "Exception: " + e.Message;
450 return friendsOnline; 358 return friendsOnline;
451 } 359 }
452 360
453 if (response.IsFault) 361 if (response.IsFault)
454 { 362 {
455 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURL, response.FaultString); 363 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURLHost, response.FaultString);
456// reason = "XMLRPC Fault"; 364// reason = "XMLRPC Fault";
457 return friendsOnline; 365 return friendsOnline;
458 } 366 }
@@ -464,7 +372,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
464 { 372 {
465 if (hash == null) 373 if (hash == null)
466 { 374 {
467 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 375 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
468// reason = "Internal error 1"; 376// reason = "Internal error 1";
469 return friendsOnline; 377 return friendsOnline;
470 } 378 }
@@ -517,14 +425,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
517 } 425 }
518 catch 426 catch
519 { 427 {
520 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL); 428 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost);
521// reason = "Exception: " + e.Message; 429// reason = "Exception: " + e.Message;
522 return online; 430 return online;
523 } 431 }
524 432
525 if (response.IsFault) 433 if (response.IsFault)
526 { 434 {
527 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString); 435 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString);
528// reason = "XMLRPC Fault"; 436// reason = "XMLRPC Fault";
529 return online; 437 return online;
530 } 438 }
@@ -536,7 +444,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
536 { 444 {
537 if (hash == null) 445 if (hash == null)
538 { 446 {
539 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 447 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
540// reason = "Internal error 1"; 448// reason = "Internal error 1";
541 return online; 449 return online;
542 } 450 }
@@ -567,51 +475,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
567 Hashtable hash = new Hashtable(); 475 Hashtable hash = new Hashtable();
568 hash["userID"] = userID.ToString(); 476 hash["userID"] = userID.ToString();
569 477
570 IList paramList = new ArrayList(); 478 hash = CallServer("get_user_info", hash);
571 paramList.Add(hash);
572
573 XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList);
574 479
575 Dictionary<string, object> info = new Dictionary<string, object>(); 480 Dictionary<string, object> info = new Dictionary<string, object>();
576 XmlRpcResponse response = null;
577 try
578 {
579 response = request.Send(m_ServerURL, 10000);
580 }
581 catch
582 {
583 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL);
584 return info;
585 }
586 481
587 if (response.IsFault) 482 foreach (object key in hash.Keys)
588 { 483 {
589 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); 484 if (hash[key] != null)
590 return info;
591 }
592
593 hash = (Hashtable)response.Value;
594 try
595 {
596 if (hash == null)
597 {
598 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
599 return info;
600 }
601
602 // Here is the actual response
603 foreach (object key in hash.Keys)
604 { 485 {
605 if (hash[key] != null) 486 info.Add(key.ToString(), hash[key]);
606 {
607 info.Add(key.ToString(), hash[key]);
608 }
609 } 487 }
610 } 488 }
611 catch
612 {
613 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
614 }
615 489
616 return info; 490 return info;
617 } 491 }
@@ -621,60 +495,16 @@ namespace OpenSim.Services.Connectors.Hypergrid
621 Hashtable hash = new Hashtable(); 495 Hashtable hash = new Hashtable();
622 hash["userID"] = userID.ToString(); 496 hash["userID"] = userID.ToString();
623 497
624 IList paramList = new ArrayList(); 498 hash = CallServer("get_server_urls", hash);
625 paramList.Add(hash); 499
626 500 Dictionary<string, object> serverURLs = new Dictionary<string, object>();
627 XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); 501 foreach (object key in hash.Keys)
628// string reason = string.Empty;
629
630 // Send and get reply
631 Dictionary<string, object> serverURLs = new Dictionary<string,object>();
632 XmlRpcResponse response = null;
633 try
634 {
635 response = request.Send(m_ServerURL, 10000);
636 }
637 catch
638 {
639 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL);
640// reason = "Exception: " + e.Message;
641 return serverURLs;
642 }
643
644 if (response.IsFault)
645 {
646 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString);
647// reason = "XMLRPC Fault";
648 return serverURLs;
649 }
650
651 hash = (Hashtable)response.Value;
652 //foreach (Object o in hash)
653 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
654 try
655 { 502 {
656 if (hash == null) 503 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
657 { 504 {
658 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 505 string serverType = key.ToString().Substring(4); // remove "SRV_"
659// reason = "Internal error 1"; 506 serverURLs.Add(serverType, hash[key].ToString());
660 return serverURLs;
661 } 507 }
662
663 // Here is the actual response
664 foreach (object key in hash.Keys)
665 {
666 if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null)
667 {
668 string serverType = key.ToString().Substring(4); // remove "SRV_"
669 serverURLs.Add(serverType, hash[key].ToString());
670 }
671 }
672
673 }
674 catch
675 {
676 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
677// reason = "Exception: " + e.Message;
678 } 508 }
679 509
680 return serverURLs; 510 return serverURLs;
@@ -685,55 +515,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
685 Hashtable hash = new Hashtable(); 515 Hashtable hash = new Hashtable();
686 hash["userID"] = userID.ToString(); 516 hash["userID"] = userID.ToString();
687 517
688 IList paramList = new ArrayList(); 518 hash = CallServer("locate_user", hash);
689 paramList.Add(hash);
690 519
691 XmlRpcRequest request = new XmlRpcRequest("locate_user", paramList);
692// string reason = string.Empty;
693
694 // Send and get reply
695 string url = string.Empty; 520 string url = string.Empty;
696 XmlRpcResponse response = null;
697 try
698 {
699 response = request.Send(m_ServerURL, 10000);
700 }
701 catch
702 {
703 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for LocateUser", m_ServerURL);
704// reason = "Exception: " + e.Message;
705 return url;
706 }
707 521
708 if (response.IsFault) 522 // Here's the actual response
709 { 523 if (hash.ContainsKey("URL"))
710 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for LocateUser returned an error: {1}", m_ServerURL, response.FaultString); 524 url = hash["URL"].ToString();
711// reason = "XMLRPC Fault";
712 return url;
713 }
714
715 hash = (Hashtable)response.Value;
716 //foreach (Object o in hash)
717 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
718 try
719 {
720 if (hash == null)
721 {
722 m_log.ErrorFormat("[USER AGENT CONNECTOR]: LocateUser Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
723// reason = "Internal error 1";
724 return url;
725 }
726
727 // Here's the actual response
728 if (hash.ContainsKey("URL"))
729 url = hash["URL"].ToString();
730
731 }
732 catch
733 {
734 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response.");
735// reason = "Exception: " + e.Message;
736 }
737 525
738 return url; 526 return url;
739 } 527 }
@@ -744,55 +532,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
744 hash["userID"] = userID.ToString(); 532 hash["userID"] = userID.ToString();
745 hash["targetUserID"] = targetUserID.ToString(); 533 hash["targetUserID"] = targetUserID.ToString();
746 534
747 IList paramList = new ArrayList(); 535 hash = CallServer("get_uui", hash);
748 paramList.Add(hash);
749
750 XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList);
751// string reason = string.Empty;
752 536
753 // Send and get reply
754 string uui = string.Empty; 537 string uui = string.Empty;
755 XmlRpcResponse response = null;
756 try
757 {
758 response = request.Send(m_ServerURL, 10000);
759 }
760 catch
761 {
762 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL);
763// reason = "Exception: " + e.Message;
764 return uui;
765 }
766
767 if (response.IsFault)
768 {
769 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString);
770// reason = "XMLRPC Fault";
771 return uui;
772 }
773
774 hash = (Hashtable)response.Value;
775 //foreach (Object o in hash)
776 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
777 try
778 {
779 if (hash == null)
780 {
781 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
782// reason = "Internal error 1";
783 return uui;
784 }
785 538
786 // Here's the actual response 539 // Here's the actual response
787 if (hash.ContainsKey("UUI")) 540 if (hash.ContainsKey("UUI"))
788 uui = hash["UUI"].ToString(); 541 uui = hash["UUI"].ToString();
789
790 }
791 catch
792 {
793 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response.");
794// reason = "Exception: " + e.Message;
795 }
796 542
797 return uui; 543 return uui;
798 } 544 }
@@ -803,54 +549,17 @@ namespace OpenSim.Services.Connectors.Hypergrid
803 hash["first"] = first; 549 hash["first"] = first;
804 hash["last"] = last; 550 hash["last"] = last;
805 551
806 IList paramList = new ArrayList(); 552 hash = CallServer("get_uuid", hash);
807 paramList.Add(hash);
808 553
809 XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); 554 if (!hash.ContainsKey("UUID"))
810 // string reason = string.Empty;
811
812 // Send and get reply
813 UUID uuid = UUID.Zero;
814 XmlRpcResponse response = null;
815 try
816 {
817 response = request.Send(m_ServerURL, 10000);
818 }
819 catch
820 { 555 {
821 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL); 556 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost));
822 // reason = "Exception: " + e.Message;
823 return uuid;
824 } 557 }
825 558
826 if (response.IsFault) 559 UUID uuid;
827 { 560 if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
828 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString);
829 // reason = "XMLRPC Fault";
830 return uuid;
831 }
832
833 hash = (Hashtable)response.Value;
834 //foreach (Object o in hash)
835 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
836 try
837 {
838 if (hash == null)
839 {
840 m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
841 // reason = "Internal error 1";
842 return uuid;
843 }
844
845 // Here's the actual response
846 if (hash.ContainsKey("UUID"))
847 UUID.TryParse(hash["UUID"].ToString(), out uuid);
848
849 }
850 catch
851 { 561 {
852 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); 562 throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString()));
853 // reason = "Exception: " + e.Message;
854 } 563 }
855 564
856 return uuid; 565 return uuid;
@@ -858,7 +567,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
858 567
859 private bool GetBoolResponse(XmlRpcRequest request, out string reason) 568 private bool GetBoolResponse(XmlRpcRequest request, out string reason)
860 { 569 {
861 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); 570 //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURLHost);
862 XmlRpcResponse response = null; 571 XmlRpcResponse response = null;
863 try 572 try
864 { 573 {
@@ -866,14 +575,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
866 } 575 }
867 catch (Exception e) 576 catch (Exception e)
868 { 577 {
869 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL); 578 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURLHost);
870 reason = "Exception: " + e.Message; 579 reason = "Exception: " + e.Message;
871 return false; 580 return false;
872 } 581 }
873 582
874 if (response.IsFault) 583 if (response.IsFault)
875 { 584 {
876 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString); 585 m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURLHost, response.FaultString);
877 reason = "XMLRPC Fault"; 586 reason = "XMLRPC Fault";
878 return false; 587 return false;
879 } 588 }
@@ -885,7 +594,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
885 { 594 {
886 if (hash == null) 595 if (hash == null)
887 { 596 {
888 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL); 597 m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost);
889 reason = "Internal error 1"; 598 reason = "Internal error 1";
890 return false; 599 return false;
891 } 600 }
@@ -896,7 +605,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
896 else 605 else
897 { 606 {
898 reason = "Internal error 2"; 607 reason = "Internal error 2";
899 m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL); 608 m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURLHost);
900 } 609 }
901 610
902 return success; 611 return success;
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
index dbce9f6..e19c23d 100644
--- a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
+++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs
@@ -123,6 +123,7 @@ namespace OpenSim.Services.Connectors.InstantMessage
123 gim["position_z"] = msg.Position.Z.ToString(); 123 gim["position_z"] = msg.Position.Z.ToString();
124 gim["region_id"] = msg.RegionID.ToString(); 124 gim["region_id"] = msg.RegionID.ToString();
125 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None); 125 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None);
126 gim["region_id"] = new UUID(msg.RegionID).ToString();
126 127
127 return gim; 128 return gim;
128 } 129 }
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index 44f5e01..7cecd93 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -33,22 +33,37 @@ using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Communications; 36
37using OpenSim.Framework.Monitoring;
37using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
39using OpenMetaverse; 40using OpenMetaverse;
40 41
41namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
42{ 43{
43 public class XInventoryServicesConnector : IInventoryService 44 public class XInventoryServicesConnector : BaseServiceConnector, IInventoryService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
47 MethodBase.GetCurrentMethod().DeclaringType); 48 MethodBase.GetCurrentMethod().DeclaringType);
48 49
50 /// <summary>
51 /// Number of requests made to the remote inventory service.
52 /// </summary>
53 public int RequestsMade { get; private set; }
54
49 private string m_ServerURI = String.Empty; 55 private string m_ServerURI = String.Empty;
50 56
51 private object m_Lock = new object(); 57 /// <summary>
58 /// Timeout for remote requests.
59 /// </summary>
60 /// <remarks>
61 /// In this case, -1 is default timeout (100 seconds), not infinite.
62 /// </remarks>
63 private int m_requestTimeoutSecs = -1;
64
65 private const double CACHE_EXPIRATION_SECONDS = 20.0;
66 private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache = new ExpiringCache<UUID,InventoryItemBase>();
52 67
53 public XInventoryServicesConnector() 68 public XInventoryServicesConnector()
54 { 69 {
@@ -60,20 +75,21 @@ namespace OpenSim.Services.Connectors
60 } 75 }
61 76
62 public XInventoryServicesConnector(IConfigSource source) 77 public XInventoryServicesConnector(IConfigSource source)
78 : base(source, "InventoryService")
63 { 79 {
64 Initialise(source); 80 Initialise(source);
65 } 81 }
66 82
67 public virtual void Initialise(IConfigSource source) 83 public virtual void Initialise(IConfigSource source)
68 { 84 {
69 IConfig assetConfig = source.Configs["InventoryService"]; 85 IConfig config = source.Configs["InventoryService"];
70 if (assetConfig == null) 86 if (config == null)
71 { 87 {
72 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); 88 m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini");
73 throw new Exception("Inventory connector init error"); 89 throw new Exception("Inventory connector init error");
74 } 90 }
75 91
76 string serviceURI = assetConfig.GetString("InventoryServerURI", 92 string serviceURI = config.GetString("InventoryServerURI",
77 String.Empty); 93 String.Empty);
78 94
79 if (serviceURI == String.Empty) 95 if (serviceURI == String.Empty)
@@ -82,6 +98,45 @@ namespace OpenSim.Services.Connectors
82 throw new Exception("Inventory connector init error"); 98 throw new Exception("Inventory connector init error");
83 } 99 }
84 m_ServerURI = serviceURI; 100 m_ServerURI = serviceURI;
101
102 m_requestTimeoutSecs = config.GetInt("RemoteRequestTimeout", m_requestTimeoutSecs);
103
104 StatsManager.RegisterStat(
105 new Stat(
106 "RequestsMade",
107 "Requests made",
108 "Number of requests made to the remove inventory service",
109 "requests",
110 "inventory",
111 serviceURI,
112 StatType.Pull,
113 MeasuresOfInterest.AverageChangeOverTime,
114 s => s.Value = RequestsMade,
115 StatVerbosity.Debug));
116 }
117
118 private bool CheckReturn(Dictionary<string, object> ret)
119 {
120 if (ret == null)
121 return false;
122
123 if (ret.Count == 0)
124 return false;
125
126 if (ret.ContainsKey("RESULT"))
127 {
128 if (ret["RESULT"] is string)
129 {
130 bool result;
131
132 if (bool.TryParse((string)ret["RESULT"], out result))
133 return result;
134
135 return false;
136 }
137 }
138
139 return true;
85 } 140 }
86 141
87 public bool CreateUserInventory(UUID principalID) 142 public bool CreateUserInventory(UUID principalID)
@@ -91,12 +146,7 @@ namespace OpenSim.Services.Connectors
91 { "PRINCIPAL", principalID.ToString() } 146 { "PRINCIPAL", principalID.ToString() }
92 }); 147 });
93 148
94 if (ret == null) 149 return CheckReturn(ret);
95 return false;
96 if (ret.Count == 0)
97 return false;
98
99 return bool.Parse(ret["RESULT"].ToString());
100 } 150 }
101 151
102 public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) 152 public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
@@ -106,9 +156,7 @@ namespace OpenSim.Services.Connectors
106 { "PRINCIPAL", principalID.ToString() } 156 { "PRINCIPAL", principalID.ToString() }
107 }); 157 });
108 158
109 if (ret == null) 159 if (!CheckReturn(ret))
110 return null;
111 if (ret.Count == 0)
112 return null; 160 return null;
113 161
114 Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; 162 Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"];
@@ -135,15 +183,13 @@ namespace OpenSim.Services.Connectors
135 { "PRINCIPAL", principalID.ToString() } 183 { "PRINCIPAL", principalID.ToString() }
136 }); 184 });
137 185
138 if (ret == null) 186 if (!CheckReturn(ret))
139 return null;
140 if (ret.Count == 0)
141 return null; 187 return null;
142 188
143 return BuildFolder((Dictionary<string, object>)ret["folder"]); 189 return BuildFolder((Dictionary<string, object>)ret["folder"]);
144 } 190 }
145 191
146 public InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 192 public InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
147 { 193 {
148 Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE", 194 Dictionary<string,object> ret = MakeRequest("GETFOLDERFORTYPE",
149 new Dictionary<string,object> { 195 new Dictionary<string,object> {
@@ -151,9 +197,7 @@ namespace OpenSim.Services.Connectors
151 { "TYPE", ((int)type).ToString() } 197 { "TYPE", ((int)type).ToString() }
152 }); 198 });
153 199
154 if (ret == null) 200 if (!CheckReturn(ret))
155 return null;
156 if (ret.Count == 0)
157 return null; 201 return null;
158 202
159 return BuildFolder((Dictionary<string, object>)ret["folder"]); 203 return BuildFolder((Dictionary<string, object>)ret["folder"]);
@@ -164,7 +208,7 @@ namespace OpenSim.Services.Connectors
164 InventoryCollection inventory = new InventoryCollection(); 208 InventoryCollection inventory = new InventoryCollection();
165 inventory.Folders = new List<InventoryFolderBase>(); 209 inventory.Folders = new List<InventoryFolderBase>();
166 inventory.Items = new List<InventoryItemBase>(); 210 inventory.Items = new List<InventoryItemBase>();
167 inventory.UserID = principalID; 211 inventory.OwnerID = principalID;
168 212
169 try 213 try
170 { 214 {
@@ -174,20 +218,20 @@ namespace OpenSim.Services.Connectors
174 { "FOLDER", folderID.ToString() } 218 { "FOLDER", folderID.ToString() }
175 }); 219 });
176 220
177 if (ret == null) 221 if (!CheckReturn(ret))
178 return null;
179 if (ret.Count == 0)
180 return null; 222 return null;
181 223
182 Dictionary<string,object> folders = 224 Dictionary<string,object> folders = ret.ContainsKey("FOLDERS") ?
183 (Dictionary<string,object>)ret["FOLDERS"]; 225 (Dictionary<string,object>)ret["FOLDERS"] : null;
184 Dictionary<string,object> items = 226 Dictionary<string,object> items = ret.ContainsKey("ITEMS") ?
185 (Dictionary<string,object>)ret["ITEMS"]; 227 (Dictionary<string, object>)ret["ITEMS"] : null;
186 228
187 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i 229 if (folders != null)
188 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o)); 230 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
189 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i 231 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
190 inventory.Items.Add(BuildItem((Dictionary<string, object>)o)); 232 if (items != null)
233 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
234 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
191 } 235 }
192 catch (Exception e) 236 catch (Exception e)
193 { 237 {
@@ -196,6 +240,87 @@ namespace OpenSim.Services.Connectors
196 240
197 return inventory; 241 return inventory;
198 } 242 }
243
244 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
245 {
246 InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
247 // m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", String.Join(",", folderIDs));
248 try
249 {
250 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
251 new Dictionary<string, object> {
252 { "PRINCIPAL", principalID.ToString() },
253 { "FOLDERS", String.Join(",", folderIDs) },
254 { "COUNT", folderIDs.Length.ToString() }
255 });
256
257 if (!CheckReturn(resultSet))
258 return null;
259
260 int i = 0;
261 foreach (KeyValuePair<string, object> kvp in resultSet)
262 {
263 InventoryCollection inventory = new InventoryCollection();
264 if (kvp.Key.StartsWith("F_"))
265 {
266 UUID fid = UUID.Zero;
267 if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i])
268 {
269 inventory.Folders = new List<InventoryFolderBase>();
270 inventory.Items = new List<InventoryItemBase>();
271
272 Dictionary<string, object> ret = (Dictionary<string, object>)kvp.Value;
273
274 if (ret.ContainsKey("FID"))
275 {
276 if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID))
277 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString());
278 }
279 else
280 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response");
281
282 inventory.Version = -1;
283 if (ret.ContainsKey("VERSION"))
284 Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version);
285 if (ret.ContainsKey("OWNER"))
286 UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID);
287
288 //m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
289
290 Dictionary<string, object> folders =
291 (Dictionary<string, object>)ret["FOLDERS"];
292 Dictionary<string, object> items =
293 (Dictionary<string, object>)ret["ITEMS"];
294
295 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
296 {
297 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
298 }
299 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
300 {
301 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
302 }
303
304 inventoryArr[i] = inventory;
305 }
306 else
307 {
308 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}",
309 folderIDs[i], fid);
310 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: {0} {1}", String.Join(",", folderIDs), String.Join(",", resultSet.Keys));
311 }
312
313 i += 1;
314 }
315 }
316 }
317 catch (Exception e)
318 {
319 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleFoldersContent: {0}", e.Message);
320 }
321
322 return inventoryArr;
323 }
199 324
200 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 325 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
201 { 326 {
@@ -205,9 +330,7 @@ namespace OpenSim.Services.Connectors
205 { "FOLDER", folderID.ToString() } 330 { "FOLDER", folderID.ToString() }
206 }); 331 });
207 332
208 if (ret == null) 333 if (!CheckReturn(ret))
209 return null;
210 if (ret.Count == 0)
211 return null; 334 return null;
212 335
213 Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; 336 Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"];
@@ -230,10 +353,7 @@ namespace OpenSim.Services.Connectors
230 { "ID", folder.ID.ToString() } 353 { "ID", folder.ID.ToString() }
231 }); 354 });
232 355
233 if (ret == null) 356 return CheckReturn(ret);
234 return false;
235
236 return bool.Parse(ret["RESULT"].ToString());
237 } 357 }
238 358
239 public bool UpdateFolder(InventoryFolderBase folder) 359 public bool UpdateFolder(InventoryFolderBase folder)
@@ -248,10 +368,7 @@ namespace OpenSim.Services.Connectors
248 { "ID", folder.ID.ToString() } 368 { "ID", folder.ID.ToString() }
249 }); 369 });
250 370
251 if (ret == null) 371 return CheckReturn(ret);
252 return false;
253
254 return bool.Parse(ret["RESULT"].ToString());
255 } 372 }
256 373
257 public bool MoveFolder(InventoryFolderBase folder) 374 public bool MoveFolder(InventoryFolderBase folder)
@@ -263,10 +380,7 @@ namespace OpenSim.Services.Connectors
263 { "PRINCIPAL", folder.Owner.ToString() } 380 { "PRINCIPAL", folder.Owner.ToString() }
264 }); 381 });
265 382
266 if (ret == null) 383 return CheckReturn(ret);
267 return false;
268
269 return bool.Parse(ret["RESULT"].ToString());
270 } 384 }
271 385
272 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) 386 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
@@ -282,10 +396,7 @@ namespace OpenSim.Services.Connectors
282 { "FOLDERS", slist } 396 { "FOLDERS", slist }
283 }); 397 });
284 398
285 if (ret == null) 399 return CheckReturn(ret);
286 return false;
287
288 return bool.Parse(ret["RESULT"].ToString());
289 } 400 }
290 401
291 public bool PurgeFolder(InventoryFolderBase folder) 402 public bool PurgeFolder(InventoryFolderBase folder)
@@ -295,17 +406,18 @@ namespace OpenSim.Services.Connectors
295 { "ID", folder.ID.ToString() } 406 { "ID", folder.ID.ToString() }
296 }); 407 });
297 408
298 if (ret == null) 409 return CheckReturn(ret);
299 return false;
300
301 return bool.Parse(ret["RESULT"].ToString());
302 } 410 }
303 411
304 public bool AddItem(InventoryItemBase item) 412 public bool AddItem(InventoryItemBase item)
305 { 413 {
414 if (item.Description == null)
415 item.Description = String.Empty;
306 if (item.CreatorData == null) 416 if (item.CreatorData == null)
307 item.CreatorData = String.Empty; 417 item.CreatorData = String.Empty;
308 Dictionary<string,object> ret = MakeRequest("ADDITEM", 418 if (item.CreatorId == null)
419 item.CreatorId = String.Empty;
420 Dictionary<string, object> ret = MakeRequest("ADDITEM",
309 new Dictionary<string,object> { 421 new Dictionary<string,object> {
310 { "AssetID", item.AssetID.ToString() }, 422 { "AssetID", item.AssetID.ToString() },
311 { "AssetType", item.AssetType.ToString() }, 423 { "AssetType", item.AssetType.ToString() },
@@ -330,10 +442,7 @@ namespace OpenSim.Services.Connectors
330 { "CreationDate", item.CreationDate.ToString() } 442 { "CreationDate", item.CreationDate.ToString() }
331 }); 443 });
332 444
333 if (ret == null) 445 return CheckReturn(ret);
334 return false;
335
336 return bool.Parse(ret["RESULT"].ToString());
337 } 446 }
338 447
339 public bool UpdateItem(InventoryItemBase item) 448 public bool UpdateItem(InventoryItemBase item)
@@ -365,10 +474,13 @@ namespace OpenSim.Services.Connectors
365 { "CreationDate", item.CreationDate.ToString() } 474 { "CreationDate", item.CreationDate.ToString() }
366 }); 475 });
367 476
368 if (ret == null) 477 bool result = CheckReturn(ret);
369 return false; 478 if (result)
479 {
480 m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
481 }
370 482
371 return bool.Parse(ret["RESULT"].ToString()); 483 return result;
372 } 484 }
373 485
374 public bool MoveItems(UUID principalID, List<InventoryItemBase> items) 486 public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
@@ -389,10 +501,7 @@ namespace OpenSim.Services.Connectors
389 { "DESTLIST", destlist } 501 { "DESTLIST", destlist }
390 }); 502 });
391 503
392 if (ret == null) 504 return CheckReturn(ret);
393 return false;
394
395 return bool.Parse(ret["RESULT"].ToString());
396 } 505 }
397 506
398 public bool DeleteItems(UUID principalID, List<UUID> itemIDs) 507 public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
@@ -408,14 +517,17 @@ namespace OpenSim.Services.Connectors
408 { "ITEMS", slist } 517 { "ITEMS", slist }
409 }); 518 });
410 519
411 if (ret == null) 520 return CheckReturn(ret);
412 return false;
413
414 return bool.Parse(ret["RESULT"].ToString());
415 } 521 }
416 522
417 public InventoryItemBase GetItem(InventoryItemBase item) 523 public InventoryItemBase GetItem(InventoryItemBase item)
418 { 524 {
525 InventoryItemBase retrieved = null;
526 if (m_ItemCache.TryGetValue(item.ID, out retrieved))
527 {
528 return retrieved;
529 }
530
419 try 531 try
420 { 532 {
421 Dictionary<string, object> ret = MakeRequest("GETITEM", 533 Dictionary<string, object> ret = MakeRequest("GETITEM",
@@ -423,19 +535,81 @@ namespace OpenSim.Services.Connectors
423 { "ID", item.ID.ToString() } 535 { "ID", item.ID.ToString() }
424 }); 536 });
425 537
426 if (ret == null) 538 if (!CheckReturn(ret))
427 return null;
428 if (ret.Count == 0)
429 return null; 539 return null;
430 540
431 return BuildItem((Dictionary<string, object>)ret["item"]); 541 retrieved = BuildItem((Dictionary<string, object>)ret["item"]);
432 } 542 }
433 catch (Exception e) 543 catch (Exception e)
434 { 544 {
435 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e); 545 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetItem: ", e);
436 } 546 }
437 547
438 return null; 548 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
549
550 return retrieved;
551 }
552
553 public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
554 {
555 //m_log.DebugFormat("[XXX]: In GetMultipleItems {0}", String.Join(",", itemIDs));
556
557 InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length];
558 // Try to get them from the cache
559 List<UUID> pending = new List<UUID>();
560 InventoryItemBase item = null;
561 int i = 0;
562 foreach (UUID id in itemIDs)
563 {
564 if (m_ItemCache.TryGetValue(id, out item))
565 itemArr[i++] = item;
566 else
567 pending.Add(id);
568 }
569
570 if (pending.Count == 0) // we're done, everything was in the cache
571 return itemArr;
572
573 try
574 {
575 Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS",
576 new Dictionary<string, object> {
577 { "PRINCIPAL", principalID.ToString() },
578 { "ITEMS", String.Join(",", pending.ToArray()) },
579 { "COUNT", pending.Count.ToString() }
580 });
581
582 if (!CheckReturn(resultSet))
583 {
584 if (i == 0)
585 return null;
586 else
587 return itemArr;
588 }
589
590 // carry over index i where we left above
591 foreach (KeyValuePair<string, object> kvp in resultSet)
592 {
593 InventoryCollection inventory = new InventoryCollection();
594 if (kvp.Key.StartsWith("item_"))
595 {
596 if (kvp.Value is Dictionary<string, object>)
597 {
598 item = BuildItem((Dictionary<string, object>)kvp.Value);
599 m_ItemCache.AddOrUpdate(item.ID, item, CACHE_EXPIRATION_SECONDS);
600 itemArr[i++] = item;
601 }
602 else
603 itemArr[i++] = null;
604 }
605 }
606 }
607 catch (Exception e)
608 {
609 m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleItems: {0}", e.Message);
610 }
611
612 return itemArr;
439 } 613 }
440 614
441 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 615 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
@@ -447,9 +621,7 @@ namespace OpenSim.Services.Connectors
447 { "ID", folder.ID.ToString() } 621 { "ID", folder.ID.ToString() }
448 }); 622 });
449 623
450 if (ret == null) 624 if (!CheckReturn(ret))
451 return null;
452 if (ret.Count == 0)
453 return null; 625 return null;
454 626
455 return BuildFolder((Dictionary<string, object>)ret["folder"]); 627 return BuildFolder((Dictionary<string, object>)ret["folder"]);
@@ -469,7 +641,7 @@ namespace OpenSim.Services.Connectors
469 { "PRINCIPAL", principalID.ToString() } 641 { "PRINCIPAL", principalID.ToString() }
470 }); 642 });
471 643
472 if (ret == null) 644 if (!CheckReturn(ret))
473 return null; 645 return null;
474 646
475 List<InventoryItemBase> items = new List<InventoryItemBase>(); 647 List<InventoryItemBase> items = new List<InventoryItemBase>();
@@ -488,51 +660,22 @@ namespace OpenSim.Services.Connectors
488 { "ASSET", assetID.ToString() } 660 { "ASSET", assetID.ToString() }
489 }); 661 });
490 662
663 // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int
491 if (ret == null) 664 if (ret == null)
492 return 0; 665 return 0;
493 666
494 return int.Parse(ret["RESULT"].ToString()); 667 if (ret.ContainsKey("RESULT"))
495 }
496
497 public InventoryCollection GetUserInventory(UUID principalID)
498 {
499 InventoryCollection inventory = new InventoryCollection();
500 inventory.Folders = new List<InventoryFolderBase>();
501 inventory.Items = new List<InventoryItemBase>();
502 inventory.UserID = principalID;
503
504 try
505 { 668 {
506 Dictionary<string, object> ret = MakeRequest("GETUSERINVENTORY", 669 if (ret["RESULT"] is string)
507 new Dictionary<string, object> { 670 {
508 { "PRINCIPAL", principalID.ToString() } 671 int intResult;
509 });
510
511 if (ret == null)
512 return null;
513 if (ret.Count == 0)
514 return null;
515
516 Dictionary<string, object> folders =
517 (Dictionary<string, object>)ret["FOLDERS"];
518 Dictionary<string, object> items =
519 (Dictionary<string, object>)ret["ITEMS"];
520 672
521 foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i 673 if (int.TryParse ((string)ret["RESULT"], out intResult))
522 inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o)); 674 return intResult;
523 foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i 675 }
524 inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
525 } 676 }
526 catch (Exception e)
527 {
528 m_log.Error("[XINVENTORY SERVICES CONNECTOR]: Exception in GetUserInventory: ", e);
529 }
530
531 return inventory;
532 }
533 677
534 public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback) 678 return 0;
535 {
536 } 679 }
537 680
538 public bool HasInventoryForUser(UUID principalID) 681 public bool HasInventoryForUser(UUID principalID)
@@ -545,13 +688,19 @@ namespace OpenSim.Services.Connectors
545 private Dictionary<string,object> MakeRequest(string method, 688 private Dictionary<string,object> MakeRequest(string method,
546 Dictionary<string,object> sendData) 689 Dictionary<string,object> sendData)
547 { 690 {
548 sendData["METHOD"] = method; 691 // Add "METHOD" as the first key in the dictionary. This ensures that it will be
692 // visible even when using partial logging ("debug http all 5").
693 Dictionary<string, object> temp = sendData;
694 sendData = new Dictionary<string,object>{ { "METHOD", method } };
695 foreach (KeyValuePair<string, object> kvp in temp)
696 sendData.Add(kvp.Key, kvp.Value);
697
698 RequestsMade++;
549 699
550 string reply = string.Empty; 700 string reply
551 lock (m_Lock) 701 = SynchronousRestFormsRequester.MakeRequest(
552 reply = SynchronousRestFormsRequester.MakeRequest("POST", 702 "POST", m_ServerURI + "/xinventory",
553 m_ServerURI + "/xinventory", 703 ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth);
554 ServerUtils.BuildQueryString(sendData));
555 704
556 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse( 705 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
557 reply); 706 reply);
@@ -619,4 +768,4 @@ namespace OpenSim.Services.Connectors
619 return item; 768 return item;
620 } 769 }
621 } 770 }
622} \ No newline at end of file 771}
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 30a73a4..034c42e 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -33,7 +33,7 @@ using System.IO;
33using System.Reflection; 33using System.Reflection;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36
37using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
38using OpenMetaverse; 38using OpenMetaverse;
39using Nwc.XmlRpc; 39using Nwc.XmlRpc;
@@ -78,7 +78,7 @@ namespace OpenSim.Services.Connectors
78 try 78 try
79 { 79 {
80 uint xpos = 0, ypos = 0; 80 uint xpos = 0, ypos = 0;
81 Utils.LongToUInts(regionHandle, out xpos, out ypos); 81 Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos);
82 GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos); 82 GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos);
83 if (info != null) // just to be sure 83 if (info != null) // just to be sure
84 { 84 {
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index 30bfb70..c91ed84 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -35,7 +35,8 @@ using System.Reflection;
35using Nini.Config; 35using Nini.Config;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using OpenSim.Framework.Communications; 38
39using OpenSim.Framework.ServiceAuth;
39using OpenSim.Server.Base; 40using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
41using OpenMetaverse; 42using OpenMetaverse;
@@ -43,7 +44,7 @@ using OpenMetaverse.StructuredData;
43 44
44namespace OpenSim.Services.Connectors 45namespace OpenSim.Services.Connectors
45{ 46{
46 public class MapImageServicesConnector : IMapImageService 47 public class MapImageServicesConnector : BaseServiceConnector, IMapImageService
47 { 48 {
48 private static readonly ILog m_log = 49 private static readonly ILog m_log =
49 LogManager.GetLogger( 50 LogManager.GetLogger(
@@ -84,26 +85,26 @@ namespace OpenSim.Services.Connectors
84 } 85 }
85 m_ServerURI = serviceURI; 86 m_ServerURI = serviceURI;
86 m_ServerURI = serviceURI.TrimEnd('/'); 87 m_ServerURI = serviceURI.TrimEnd('/');
88 base.Initialise(source, "MapImageService");
87 } 89 }
88 90
89 public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) 91 public bool RemoveMapTile(int x, int y, out string reason)
90 { 92 {
91 reason = string.Empty; 93 reason = string.Empty;
92 int tickstart = Util.EnvironmentTickCount(); 94 int tickstart = Util.EnvironmentTickCount();
93 Dictionary<string, object> sendData = new Dictionary<string, object>(); 95 Dictionary<string, object> sendData = new Dictionary<string, object>();
94 sendData["X"] = x.ToString(); 96 sendData["X"] = x.ToString();
95 sendData["Y"] = y.ToString(); 97 sendData["Y"] = y.ToString();
96 sendData["TYPE"] = "image/jpeg";
97 sendData["DATA"] = Convert.ToBase64String(jpgData);
98 98
99 string reqString = ServerUtils.BuildQueryString(sendData); 99 string reqString = ServerUtils.BuildQueryString(sendData);
100 string uri = m_ServerURI + "/map"; 100 string uri = m_ServerURI + "/removemap";
101 101
102 try 102 try
103 { 103 {
104 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 104 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
105 uri, 105 uri,
106 reqString); 106 reqString,
107 m_Auth);
107 if (reply != string.Empty) 108 if (reply != string.Empty)
108 { 109 {
109 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -114,7 +115,7 @@ namespace OpenSim.Services.Connectors
114 } 115 }
115 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) 116 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
116 { 117 {
117 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString()); 118 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString());
118 reason = replyData["Message"].ToString(); 119 reason = replyData["Message"].ToString();
119 return false; 120 return false;
120 } 121 }
@@ -142,6 +143,72 @@ namespace OpenSim.Services.Connectors
142 { 143 {
143 // This just dumps a warning for any operation that takes more than 100 ms 144 // This just dumps a warning for any operation that takes more than 100 ms
144 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 145 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
146 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff);
147 }
148
149 return false;
150 }
151
152 public bool AddMapTile(int x, int y, byte[] jpgData, out string reason)
153 {
154 reason = string.Empty;
155 int tickstart = Util.EnvironmentTickCount();
156 Dictionary<string, object> sendData = new Dictionary<string, object>();
157 sendData["X"] = x.ToString();
158 sendData["Y"] = y.ToString();
159 sendData["TYPE"] = "image/jpeg";
160 sendData["DATA"] = Convert.ToBase64String(jpgData);
161
162 string reqString = ServerUtils.BuildQueryString(sendData);
163 string uri = m_ServerURI + "/map";
164
165 try
166 {
167 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
168 uri,
169 reqString,
170 m_Auth);
171 if (reply != string.Empty)
172 {
173 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
174
175 if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
176 {
177 return true;
178 }
179 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
180 {
181 reason = string.Format("Map post to {0} failed: {1}", uri, replyData["Message"].ToString());
182 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
183
184 return false;
185 }
186 else if (!replyData.ContainsKey("Result"))
187 {
188 reason = string.Format("Reply data from {0} does not contain result field", uri);
189 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
190 }
191 else
192 {
193 reason = string.Format("Unexpected result {0} from {1}" + replyData["Result"].ToString(), uri);
194 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
195 }
196 }
197 else
198 {
199 reason = string.Format("Map post received null reply from {0}", uri);
200 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
201 }
202 }
203 catch (Exception e)
204 {
205 reason = string.Format("Exception when posting to map server at {0}: {1}", uri, e.Message);
206 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
207 }
208 finally
209 {
210 // This just dumps a warning for any operation that takes more than 100 ms
211 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
145 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff); 212 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile uploaded in {0}ms", tickdiff);
146 } 213 }
147 214
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 7429293..925364a 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -35,7 +35,7 @@ using System.Reflection;
35using System.Text; 35using System.Text;
36using Nini.Config; 36using Nini.Config;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenMetaverse; 40using OpenMetaverse;
41using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors
69 public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 69 public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
70 { 70 {
71 uint x = 0, y = 0; 71 uint x = 0, y = 0;
72 Utils.LongToUInts(regionHandle, out x, out y); 72 Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
73 GridRegion regInfo = m_GridService.GetRegionByPosition(thisRegion.ScopeID, (int)x, (int)y); 73 GridRegion regInfo = m_GridService.GetRegionByPosition(thisRegion.ScopeID, (int)x, (int)y);
74 if ((regInfo != null) && 74 if ((regInfo != null) &&
75 // Don't remote-call this instance; that's a startup hickup 75 // Don't remote-call this instance; that's a startup hickup
@@ -97,9 +97,9 @@ namespace OpenSim.Services.Connectors
97 } 97 }
98 catch (Exception e) 98 catch (Exception e)
99 { 99 {
100 m_log.WarnFormat( 100 m_log.Warn(string.Format(
101 "[NEIGHBOUR SERVICE CONNCTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3}{4}", 101 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3} ",
102 uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 102 uri, thisRegion.RegionName, region.RegionName, e.Message), e);
103 103
104 return false; 104 return false;
105 } 105 }
@@ -116,9 +116,9 @@ namespace OpenSim.Services.Connectors
116 } 116 }
117 catch (Exception e) 117 catch (Exception e)
118 { 118 {
119 m_log.WarnFormat( 119 m_log.Warn(string.Format(
120 "[NEIGHBOUR SERVICE CONNCTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2}{3}", 120 "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2} ",
121 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 121 thisRegion.RegionName, region.RegionName, e.Message), e);
122 122
123 return false; 123 return false;
124 } 124 }
@@ -136,9 +136,9 @@ namespace OpenSim.Services.Connectors
136 } 136 }
137 catch (Exception e) 137 catch (Exception e)
138 { 138 {
139 m_log.WarnFormat( 139 m_log.Warn(string.Format(
140 "[NEIGHBOUR SERVICE CONNCTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2}{3}", 140 "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2} ",
141 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 141 thisRegion.RegionName, region.RegionName, e.Message), e);
142 142
143 return false; 143 return false;
144 } 144 }
@@ -153,53 +153,53 @@ namespace OpenSim.Services.Connectors
153 } 153 }
154 catch (Exception e) 154 catch (Exception e)
155 { 155 {
156 m_log.WarnFormat( 156 m_log.Warn(string.Format(
157 "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}", 157 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ",
158 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 158 thisRegion.RegionName, region.RegionName, uri, e.Message), e);
159 159
160 return false; 160 return false;
161 } 161 }
162 finally 162 finally
163 { 163 {
164 if (os != null) 164 if (os != null)
165 os.Close(); 165 os.Dispose();
166 } 166 }
167 167
168 // Let's wait for the response 168 // Let's wait for the response
169 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); 169 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
170 170
171 StreamReader sr = null;
172 try 171 try
173 { 172 {
174 WebResponse webResponse = helloNeighbourRequest.GetResponse(); 173 using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
175 if (webResponse == null)
176 { 174 {
177 m_log.DebugFormat( 175 if (webResponse == null)
178 "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}", 176 {
179 thisRegion.RegionName, region.RegionName); 177 m_log.DebugFormat(
178 "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
179 thisRegion.RegionName, region.RegionName);
180 }
181
182 using (Stream s = webResponse.GetResponseStream())
183 {
184 using (StreamReader sr = new StreamReader(s))
185 {
186 //reply = sr.ReadToEnd().Trim();
187 sr.ReadToEnd().Trim();
188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
189 }
190 }
180 } 191 }
181
182 sr = new StreamReader(webResponse.GetResponseStream());
183 //reply = sr.ReadToEnd().Trim();
184 sr.ReadToEnd().Trim();
185 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
186
187 } 192 }
188 catch (Exception e) 193 catch (Exception e)
189 { 194 {
190 m_log.WarnFormat( 195 m_log.Warn(string.Format(
191 "[NEIGHBOUR SERVICE CONNCTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2}{3}", 196 "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2} ",
192 region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace); 197 region.RegionName, thisRegion.RegionName, e.Message), e);
193 198
194 return false; 199 return false;
195 } 200 }
196 finally
197 {
198 if (sr != null)
199 sr.Close();
200 }
201 201
202 return true; 202 return true;
203 } 203 }
204 } 204 }
205} \ No newline at end of file 205}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index f7d8c53..b7e95c4 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -32,7 +32,8 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35
36using OpenSim.Framework.ServiceAuth;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion; 38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
@@ -40,7 +41,7 @@ using OpenMetaverse;
40 41
41namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
42{ 43{
43 public class PresenceServicesConnector : IPresenceService 44 public class PresenceServicesConnector : BaseServiceConnector, IPresenceService
44 { 45 {
45 private static readonly ILog m_log = 46 private static readonly ILog m_log =
46 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -80,6 +81,8 @@ namespace OpenSim.Services.Connectors
80 throw new Exception("Presence connector init error"); 81 throw new Exception("Presence connector init error");
81 } 82 }
82 m_ServerURI = serviceURI; 83 m_ServerURI = serviceURI;
84
85 base.Initialise(source, "PresenceService");
83 } 86 }
84 87
85 88
@@ -104,7 +107,8 @@ namespace OpenSim.Services.Connectors
104 { 107 {
105 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 108 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
106 uri, 109 uri,
107 reqString); 110 reqString,
111 m_Auth);
108 if (reply != string.Empty) 112 if (reply != string.Empty)
109 { 113 {
110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 114 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -149,7 +153,8 @@ namespace OpenSim.Services.Connectors
149 { 153 {
150 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 154 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
151 uri, 155 uri,
152 reqString); 156 reqString,
157 m_Auth);
153 if (reply != string.Empty) 158 if (reply != string.Empty)
154 { 159 {
155 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 160 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -193,7 +198,8 @@ namespace OpenSim.Services.Connectors
193 { 198 {
194 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 199 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
195 uri, 200 uri,
196 reqString); 201 reqString,
202 m_Auth);
197 if (reply != string.Empty) 203 if (reply != string.Empty)
198 { 204 {
199 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 205 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -238,7 +244,8 @@ namespace OpenSim.Services.Connectors
238 { 244 {
239 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 245 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
240 uri, 246 uri,
241 reqString); 247 reqString,
248 m_Auth);
242 if (reply != string.Empty) 249 if (reply != string.Empty)
243 { 250 {
244 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 251 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -283,7 +290,8 @@ namespace OpenSim.Services.Connectors
283 { 290 {
284 reply = SynchronousRestFormsRequester.MakeRequest("POST", 291 reply = SynchronousRestFormsRequester.MakeRequest("POST",
285 uri, 292 uri,
286 reqString); 293 reqString,
294 m_Auth);
287 if (reply == null || (reply != null && reply == string.Empty)) 295 if (reply == null || (reply != null && reply == string.Empty))
288 { 296 {
289 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply"); 297 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgent received null or empty reply");
@@ -293,6 +301,7 @@ namespace OpenSim.Services.Connectors
293 catch (Exception e) 301 catch (Exception e)
294 { 302 {
295 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message); 303 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
304 return null;
296 } 305 }
297 306
298 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 307 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
@@ -327,7 +336,8 @@ namespace OpenSim.Services.Connectors
327 { 336 {
328 reply = SynchronousRestFormsRequester.MakeRequest("POST", 337 reply = SynchronousRestFormsRequester.MakeRequest("POST",
329 uri, 338 uri,
330 reqString); 339 reqString,
340 m_Auth);
331 if (reply == null || (reply != null && reply == string.Empty)) 341 if (reply == null || (reply != null && reply == string.Empty))
332 { 342 {
333 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null or empty reply"); 343 m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents received null or empty reply");
diff --git a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
index bfb681b..c581a59 100644
--- a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.7.5.*")] 32[assembly: AssemblyVersion("0.8.3.*")]
33[assembly: AssemblyFileVersion("1.0.0.0")] 33
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
index 95e4bab..cd4781d 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
69 Util.FireAndForget(delegate(object o) 69 Util.FireAndForget(delegate(object o)
70 { 70 {
71 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 71 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
72 }); 72 }, null, "SimianActivityDetector.SetLastPositionOnMakeRootAgent");
73 } 73 }
74 74
75 public void OnNewClient(IClientAPI client) 75 public void OnNewClient(IClientAPI client)
@@ -94,7 +94,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
94 Util.FireAndForget(delegate(object o) 94 Util.FireAndForget(delegate(object o)
95 { 95 {
96 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 96 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
97 }); 97 }, null, "SimianActivityDetector.SetLastPositionOnEnteringNewParcel");
98 } 98 }
99 } 99 }
100} \ No newline at end of file 100} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 63a32e7..9ad4a7a 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
@@ -122,7 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
122 m_Enabled = true; 123 m_Enabled = true;
123 } 124 }
124 125
125 #region IAssetService 126#region IAssetService
126 127
127 public AssetBase Get(string id) 128 public AssetBase Get(string id)
128 { 129 {
@@ -140,8 +141,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
140 return asset; 141 return asset;
141 } 142 }
142 143
143 return GetRemote(id); 144 return SimianGetOperation(id);
144 } 145 }
146
145 147
146 public AssetBase GetCached(string id) 148 public AssetBase GetCached(string id)
147 { 149 {
@@ -164,8 +166,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
164 throw new InvalidOperationException(); 166 throw new InvalidOperationException();
165 } 167 }
166 168
167 AssetMetadata metadata = null;
168
169 // Cache fetch 169 // Cache fetch
170 if (m_cache != null) 170 if (m_cache != null)
171 { 171 {
@@ -174,50 +174,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
174 return asset.Metadata; 174 return asset.Metadata;
175 } 175 }
176 176
177 Uri url; 177 // return GetRemoteMetadata(id);
178 178 return SimianGetMetadataOperation(id);
179 // Determine if id is an absolute URL or a grid-relative UUID
180 if (!Uri.TryCreate(id, UriKind.Absolute, out url))
181 url = new Uri(m_serverUrl + id);
182
183 try
184 {
185 HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
186 request.Method = "HEAD";
187
188 using (WebResponse response = request.GetResponse())
189 {
190 using (Stream responseStream = response.GetResponseStream())
191 {
192 // Create the metadata object
193 metadata = new AssetMetadata();
194 metadata.ContentType = response.ContentType;
195 metadata.ID = id;
196
197 UUID uuid;
198 if (UUID.TryParse(id, out uuid))
199 metadata.FullID = uuid;
200
201 string lastModifiedStr = response.Headers.Get("Last-Modified");
202 if (!String.IsNullOrEmpty(lastModifiedStr))
203 {
204 DateTime lastModified;
205 if (DateTime.TryParse(lastModifiedStr, out lastModified))
206 metadata.CreationDate = lastModified;
207 }
208 }
209 }
210 }
211 catch (Exception ex)
212 {
213 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
214 }
215
216 return metadata;
217 } 179 }
218 180
219 public byte[] GetData(string id) 181 public byte[] GetData(string id)
220 { 182 {
183 if (String.IsNullOrEmpty(m_serverUrl))
184 {
185 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
186 throw new InvalidOperationException();
187 }
188
221 AssetBase asset = Get(id); 189 AssetBase asset = Get(id);
222 190
223 if (asset != null) 191 if (asset != null)
@@ -255,14 +223,34 @@ namespace OpenSim.Services.Connectors.SimianGrid
255 Util.FireAndForget( 223 Util.FireAndForget(
256 delegate(object o) 224 delegate(object o)
257 { 225 {
258 AssetBase asset = GetRemote(id); 226 AssetBase asset = SimianGetOperation(id);
259 handler(id, sender, asset); 227 handler(id, sender, asset);
260 } 228 }, null, "SimianAssetServiceConnector.GetFromService"
261 ); 229 );
262 230
263 return true; 231 return true;
264 } 232 }
265 233
234 public bool[] AssetsExist(string[] ids)
235 {
236 if (String.IsNullOrEmpty(m_serverUrl))
237 {
238 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
239 throw new InvalidOperationException();
240 }
241
242 bool[] exist = new bool[ids.Length];
243
244 for (int i = 0; i < ids.Length; i++)
245 {
246 AssetMetadata metadata = GetMetadata(ids[i]);
247 if (metadata != null)
248 exist[i] = true;
249 }
250
251 return exist;
252 }
253
266 /// <summary> 254 /// <summary>
267 /// Creates a new asset 255 /// Creates a new asset
268 /// </summary> 256 /// </summary>
@@ -278,7 +266,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
278 } 266 }
279 267
280 bool storedInCache = false; 268 bool storedInCache = false;
281 string errorMessage = null;
282 269
283 // AssetID handling 270 // AssetID handling
284 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) 271 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID)
@@ -307,80 +294,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
307 return asset.ID; 294 return asset.ID;
308 } 295 }
309 296
310 // Distinguish public and private assets 297 return SimianStoreOperation(asset);
311 bool isPublic = true;
312 switch ((AssetType)asset.Type)
313 {
314 case AssetType.CallingCard:
315 case AssetType.Gesture:
316 case AssetType.LSLBytecode:
317 case AssetType.LSLText:
318 isPublic = false;
319 break;
320 }
321
322 // Make sure ContentType is set
323 if (String.IsNullOrEmpty(asset.Metadata.ContentType))
324 asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type);
325
326 // Build the remote storage request
327 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
328 {
329 new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
330 new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
331 new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
332 new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
333 new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
334 };
335
336 // Make the remote storage request
337 try
338 {
339 // Simian does not require the asset ID to be in the URL because it's in the post data.
340 // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
341 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
342
343 HttpWebResponse response = MultipartForm.Post(request, postParameters);
344 using (Stream responseStream = response.GetResponseStream())
345 {
346 string responseStr = null;
347
348 try
349 {
350 responseStr = responseStream.GetStreamString();
351 OSD responseOSD = OSDParser.Deserialize(responseStr);
352 if (responseOSD.Type == OSDType.Map)
353 {
354 OSDMap responseMap = (OSDMap)responseOSD;
355 if (responseMap["Success"].AsBoolean())
356 return asset.ID;
357 else
358 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
359 }
360 else
361 {
362 errorMessage = "Response format was invalid:\n" + responseStr;
363 }
364 }
365 catch (Exception ex)
366 {
367 if (!String.IsNullOrEmpty(responseStr))
368 errorMessage = "Failed to parse the response:\n" + responseStr;
369 else
370 errorMessage = "Failed to retrieve the response: " + ex.Message;
371 }
372 }
373 }
374 catch (WebException ex)
375 {
376 errorMessage = ex.Message;
377 }
378
379 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
380 asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
381 return null;
382 } 298 }
383 299
384 /// <summary> 300 /// <summary>
385 /// Update an asset's content 301 /// Update an asset's content
386 /// </summary> 302 /// </summary>
@@ -390,11 +306,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
390 /// <returns></returns> 306 /// <returns></returns>
391 public bool UpdateContent(string id, byte[] data) 307 public bool UpdateContent(string id, byte[] data)
392 { 308 {
309 if (String.IsNullOrEmpty(m_serverUrl))
310 {
311 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
312 throw new InvalidOperationException();
313 }
314
393 AssetBase asset = Get(id); 315 AssetBase asset = Get(id);
394 316
395 if (asset == null) 317 if (asset == null)
396 { 318 {
397 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating"); 319 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id);
398 return false; 320 return false;
399 } 321 }
400 322
@@ -417,83 +339,347 @@ namespace OpenSim.Services.Connectors.SimianGrid
417 throw new InvalidOperationException(); 339 throw new InvalidOperationException();
418 } 340 }
419 341
420 //string errorMessage = String.Empty;
421 string url = m_serverUrl + id;
422
423 if (m_cache != null) 342 if (m_cache != null)
424 m_cache.Expire(id); 343 m_cache.Expire(id);
425 344
345 return SimianDeleteOperation(id);
346 }
347
348#endregion IAssetService
349
350#region SimianOperations
351 /// <summary>
352 /// Invokes the xRemoveAsset operation on the simian server to delete an asset
353 /// </summary>
354 /// <param name="id"></param>
355 /// <returns></returns>
356 private bool SimianDeleteOperation(string id)
357 {
426 try 358 try
427 { 359 {
428 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); 360 NameValueCollection requestArgs = new NameValueCollection
429 request.Method = "DELETE"; 361 {
362 { "RequestMethod", "xRemoveAsset" },
363 { "AssetID", id }
364 };
430 365
431 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 366 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
367 if (! response["Success"].AsBoolean())
432 { 368 {
433 if (response.StatusCode != HttpStatusCode.NoContent) 369 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
434 { 370 return false;
435 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " +
436 response.StatusCode + " (" + response.StatusDescription + ")");
437 }
438 } 371 }
439 372
440 return true; 373 return true;
374
441 } 375 }
442 catch (Exception ex) 376 catch (Exception ex)
443 { 377 {
444 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message); 378 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message);
445 return false;
446 } 379 }
447 }
448 380
449 #endregion IAssetService 381 return false;
382 }
450 383
451 private AssetBase GetRemote(string id) 384 /// <summary>
385 /// Invokes the xAddAsset operation on the simian server to create or update an asset
386 /// </summary>
387 /// <param name="id"></param>
388 /// <returns></returns>
389 private string SimianStoreOperation(AssetBase asset)
452 { 390 {
453 AssetBase asset = null; 391 try
454 Uri url; 392 {
393 NameValueCollection requestArgs = new NameValueCollection
394 {
395 { "RequestMethod", "xAddAsset" },
396 { "ContentType", asset.Metadata.ContentType },
397 { "EncodedData", Convert.ToBase64String(asset.Data) },
398 { "AssetID", asset.FullID.ToString() },
399 { "CreatorID", asset.Metadata.CreatorID },
400 { "Temporary", asset.Temporary ? "1" : "0" },
401 { "Name", asset.Name }
402 };
403
404 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
405 if (! response["Success"].AsBoolean())
406 {
407 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString());
408 return null;
409 }
455 410
456 // Determine if id is an absolute URL or a grid-relative UUID 411 // asset.ID is always set before calling this function
457 if (!Uri.TryCreate(id, UriKind.Absolute, out url)) 412 return asset.ID;
458 url = new Uri(m_serverUrl + id); 413
414 }
415 catch (Exception ex)
416 {
417 m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
418 }
419
420 return null;
421 }
459 422
460 try 423 /// <summary>
424 /// Invokes the xGetAsset operation on the simian server to get data associated with an asset
425 /// </summary>
426 /// <param name="id"></param>
427 /// <returns></returns>
428 private AssetBase SimianGetOperation(string id)
429 {
430 try
461 { 431 {
462 HttpWebRequest request = UntrustedHttpWebRequest.Create(url); 432 NameValueCollection requestArgs = new NameValueCollection
433 {
434 { "RequestMethod", "xGetAsset" },
435 { "ID", id }
436 };
463 437
464 using (WebResponse response = request.GetResponse()) 438 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
439 if (! response["Success"].AsBoolean())
465 { 440 {
466 using (Stream responseStream = response.GetResponseStream()) 441 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
467 { 442 return null;
468 string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
469
470 // Create the asset object
471 asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
472
473 UUID assetID;
474 if (UUID.TryParse(id, out assetID))
475 asset.FullID = assetID;
476
477 // Grab the asset data from the response stream
478 using (MemoryStream stream = new MemoryStream())
479 {
480 responseStream.CopyStream(stream, Int32.MaxValue);
481 asset.Data = stream.ToArray();
482 }
483 }
484 } 443 }
444
445 AssetBase asset = new AssetBase();
485 446
486 // Cache store 447 asset.ID = id;
487 if (m_cache != null && asset != null) 448 asset.Name = String.Empty;
488 m_cache.Cache(asset); 449 asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property
450 asset.CreatorID = response["CreatorID"].AsString();
451 asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString());
452 asset.Local = false;
453 asset.Temporary = response["Temporary"];
489 454
490 return asset; 455 return asset;
491 } 456 }
492 catch (Exception ex) 457 catch (Exception ex)
493 { 458 {
494 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); 459 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message);
495 return null; 460 }
461
462 return null;
463 }
464
465 /// <summary>
466 /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset
467 /// This operation is generally used to determine if an asset exists in the database
468 /// </summary>
469 /// <param name="id"></param>
470 /// <returns></returns>
471 private AssetMetadata SimianGetMetadataOperation(string id)
472 {
473 try
474 {
475 NameValueCollection requestArgs = new NameValueCollection
476 {
477 { "RequestMethod", "xGetAssetMetadata" },
478 { "ID", id }
479 };
480
481 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
482 if (! response["Success"].AsBoolean())
483 {
484 // this is not really an error, this call is used to test existence
485 // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
486 return null;
487 }
488
489 AssetMetadata metadata = new AssetMetadata();
490 metadata.ID = id;
491 metadata.ContentType = response["ContentType"].AsString();
492 metadata.CreatorID = response["CreatorID"].AsString();
493 metadata.Local = false;
494 metadata.Temporary = response["Temporary"];
495
496 string lastModifiedStr = response["Last-Modified"].AsString();
497 if (! String.IsNullOrEmpty(lastModifiedStr))
498 {
499 DateTime lastModified;
500 if (DateTime.TryParse(lastModifiedStr, out lastModified))
501 metadata.CreationDate = lastModified;
502 }
503
504 return metadata;
505 }
506 catch (Exception ex)
507 {
508 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message);
496 } 509 }
510
511 return null;
497 } 512 }
513#endregion
514
515 // private AssetMetadata GetRemoteMetadata(string id)
516 // {
517 // Uri url;
518 // AssetMetadata metadata = null;
519
520 // // Determine if id is an absolute URL or a grid-relative UUID
521 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
522 // url = new Uri(m_serverUrl + id);
523
524 // try
525 // {
526 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
527 // request.Method = "HEAD";
528
529 // using (WebResponse response = request.GetResponse())
530 // {
531 // using (Stream responseStream = response.GetResponseStream())
532 // {
533 // // Create the metadata object
534 // metadata = new AssetMetadata();
535 // metadata.ContentType = response.ContentType;
536 // metadata.ID = id;
537
538 // UUID uuid;
539 // if (UUID.TryParse(id, out uuid))
540 // metadata.FullID = uuid;
541
542 // string lastModifiedStr = response.Headers.Get("Last-Modified");
543 // if (!String.IsNullOrEmpty(lastModifiedStr))
544 // {
545 // DateTime lastModified;
546 // if (DateTime.TryParse(lastModifiedStr, out lastModified))
547 // metadata.CreationDate = lastModified;
548 // }
549 // }
550 // }
551 // }
552 // catch (Exception ex)
553 // {
554 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
555 // }
556
557 // return metadata;
558 // }
559
560 // private AssetBase GetRemote(string id)
561 // {
562 // AssetBase asset = null;
563 // Uri url;
564
565 // // Determine if id is an absolute URL or a grid-relative UUID
566 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
567 // url = new Uri(m_serverUrl + id);
568
569 // try
570 // {
571 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
572
573 // using (WebResponse response = request.GetResponse())
574 // {
575 // using (Stream responseStream = response.GetResponseStream())
576 // {
577 // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
578
579 // // Create the asset object
580 // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
581
582 // UUID assetID;
583 // if (UUID.TryParse(id, out assetID))
584 // asset.FullID = assetID;
585
586 // // Grab the asset data from the response stream
587 // using (MemoryStream stream = new MemoryStream())
588 // {
589 // responseStream.CopyStream(stream, Int32.MaxValue);
590 // asset.Data = stream.ToArray();
591 // }
592 // }
593 // }
594
595 // // Cache store
596 // if (m_cache != null && asset != null)
597 // m_cache.Cache(asset);
598
599 // return asset;
600 // }
601 // catch (Exception ex)
602 // {
603 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
604 // return null;
605 // }
606 // }
607
608 // private string StoreRemote(AssetBase asset)
609 // {
610 // // Distinguish public and private assets
611 // bool isPublic = true;
612 // switch ((AssetType)asset.Type)
613 // {
614 // case AssetType.CallingCard:
615 // case AssetType.Gesture:
616 // case AssetType.LSLBytecode:
617 // case AssetType.LSLText:
618 // isPublic = false;
619 // break;
620 // }
621
622 // string errorMessage = null;
623
624 // // Build the remote storage request
625 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
626 // {
627 // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
628 // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
629 // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
630 // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
631 // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
632 // };
633
634 // // Make the remote storage request
635 // try
636 // {
637 // // Simian does not require the asset ID to be in the URL because it's in the post data.
638 // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
639 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
640
641 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
642 // {
643 // using (Stream responseStream = response.GetResponseStream())
644 // {
645 // string responseStr = null;
646
647 // try
648 // {
649 // responseStr = responseStream.GetStreamString();
650 // OSD responseOSD = OSDParser.Deserialize(responseStr);
651 // if (responseOSD.Type == OSDType.Map)
652 // {
653 // OSDMap responseMap = (OSDMap)responseOSD;
654 // if (responseMap["Success"].AsBoolean())
655 // return asset.ID;
656 // else
657 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
658 // }
659 // else
660 // {
661 // errorMessage = "Response format was invalid:\n" + responseStr;
662 // }
663 // }
664 // catch (Exception ex)
665 // {
666 // if (!String.IsNullOrEmpty(responseStr))
667 // errorMessage = "Failed to parse the response:\n" + responseStr;
668 // else
669 // errorMessage = "Failed to retrieve the response: " + ex.Message;
670 // }
671 // }
672 // }
673 // }
674 // catch (WebException ex)
675 // {
676 // errorMessage = ex.Message;
677 // }
678
679 // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
680 // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
681
682 // return null;
683 // }
498 } 684 }
499} 685}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 6603f6e..3bd11d9 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
110 { "UserID", principalID.ToString() } 110 { "UserID", principalID.ToString() }
111 }; 111 };
112 112
113 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 113 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
114 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) 114 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
115 { 115 {
116 bool md5hashFound = false; 116 bool md5hashFound = false;
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
153 { "SessionID", token } 153 { "SessionID", token }
154 }; 154 };
155 155
156 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 156 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
157 if (response["Success"].AsBoolean()) 157 if (response["Success"].AsBoolean())
158 { 158 {
159 return true; 159 return true;
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
175 { "UserID", principalID.ToString() } 175 { "UserID", principalID.ToString() }
176 }; 176 };
177 177
178 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 178 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
179 if (response["Success"].AsBoolean()) 179 if (response["Success"].AsBoolean())
180 { 180 {
181 return true; 181 return true;
@@ -198,7 +198,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
198 { "UserID", principalID.ToString() } 198 { "UserID", principalID.ToString() }
199 }; 199 };
200 200
201 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 201 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
202 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 202 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
203 { 203 {
204 OSDMap userMap = (OSDMap)response["User"]; 204 OSDMap userMap = (OSDMap)response["User"];
@@ -218,7 +218,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
218 { "UserID", principalID.ToString() } 218 { "UserID", principalID.ToString() }
219 }; 219 };
220 220
221 response = WebUtil.PostToService(m_serverUrl, requestArgs); 221 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
222 bool success = response["Success"].AsBoolean(); 222 bool success = response["Success"].AsBoolean();
223 223
224 if (!success) 224 if (!success)
@@ -297,7 +297,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
297 { "UserID", userID.ToString() } 297 { "UserID", userID.ToString() }
298 }; 298 };
299 299
300 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 300 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
301 if (response["Success"].AsBoolean()) 301 if (response["Success"].AsBoolean())
302 return response["SessionID"].AsUUID().ToString(); 302 return response["SessionID"].AsUUID().ToString();
303 else 303 else
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index 841bfa0..a397740 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
122 { "UserID", userID.ToString() } 122 { "UserID", userID.ToString() }
123 }; 123 };
124 124
125 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 125 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
126 if (response["Success"].AsBoolean()) 126 if (response["Success"].AsBoolean())
127 { 127 {
128 OSDMap map = null; 128 OSDMap map = null;
@@ -168,7 +168,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
168 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } 168 { "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
169 }; 169 };
170 170
171 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 171 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
172 bool success = response["Success"].AsBoolean(); 172 bool success = response["Success"].AsBoolean();
173 173
174 if (! success) 174 if (! success)
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 { "UserID", userID.ToString() } 189 { "UserID", userID.ToString() }
190 }; 190 };
191 191
192 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 192 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
193 if (response["Success"].AsBoolean()) 193 if (response["Success"].AsBoolean())
194 { 194 {
195 OSDMap map = null; 195 OSDMap map = null;
@@ -306,7 +306,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
306 { "LLAttachments", OSDParser.SerializeJsonString(items) } 306 { "LLAttachments", OSDParser.SerializeJsonString(items) }
307 }; 307 };
308 308
309 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 309 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
310 bool success = response["Success"].AsBoolean(); 310 bool success = response["Success"].AsBoolean();
311 311
312 if (!success) 312 if (!success)
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
new file mode 100644
index 0000000..764e71f
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs
@@ -0,0 +1,180 @@
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 System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.IO;
33using System.Web;
34
35using log4net;
36using Nini.Config;
37using Mono.Addins;
38
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41
42using OpenSim.Framework;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Services.Interfaces;
46using Caps = OpenSim.Framework.Capabilities.Caps;
47
48namespace OpenSim.Services.Connectors.SimianGrid
49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
51 public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule
52 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
55 private bool m_enabled = true;
56 private Scene m_scene;
57 private String m_simianURL;
58
59#region IRegionModule Members
60
61 public string Name
62 {
63 get { return this.GetType().Name; }
64 }
65
66 public void Initialise(IConfigSource config)
67 {
68 try
69 {
70 IConfig m_config;
71
72 if ((m_config = config.Configs["SimianExternalCaps"]) != null)
73 {
74 m_enabled = m_config.GetBoolean("Enabled", m_enabled);
75 if ((m_config = config.Configs["SimianGrid"]) != null)
76 {
77 m_simianURL = m_config.GetString("SimianServiceURL");
78 if (String.IsNullOrEmpty(m_simianURL))
79 {
80 //m_log.DebugFormat("[SimianGrid] service URL is not defined");
81 m_enabled = false;
82 return;
83 }
84 }
85 }
86 else
87 m_enabled = false;
88 }
89 catch (Exception e)
90 {
91 m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
92 return;
93 }
94 }
95
96 public void PostInitialise() { }
97 public void Close() { }
98
99 public void AddRegion(Scene scene)
100 {
101 if (! m_enabled)
102 return;
103
104 m_scene = scene;
105 m_scene.RegisterModuleInterface<IExternalCapsModule>(this);
106 }
107
108 public void RemoveRegion(Scene scene)
109 {
110 if (! m_enabled)
111 return;
112
113 m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler;
114 m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler;
115 }
116
117 public void RegionLoaded(Scene scene)
118 {
119 if (! m_enabled)
120 return;
121
122 m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler;
123 m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler;
124 }
125
126 public Type ReplaceableInterface
127 {
128 get { return null; }
129 }
130
131#endregion
132
133#region IExternalCapsModule
134 // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/"
135 public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel)
136 {
137 UUID cap = UUID.Random();
138
139 // Call to simian to register the cap we generated
140 // NameValueCollection requestArgs = new NameValueCollection
141 // {
142 // { "RequestMethod", "AddCapability" },
143 // { "Resource", "user" },
144 // { "Expiration", 0 },
145 // { "OwnerID", agentID.ToString() },
146 // { "CapabilityID", cap.ToString() }
147 // };
148
149 // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs);
150
151 Dictionary<String,String> subs = new Dictionary<String,String>();
152 subs["%OP%"] = capName;
153 subs["%USR%"] = agentID.ToString();
154 subs["%CAP%"] = cap.ToString();
155 subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString();
156
157 caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs));
158 return true;
159 }
160
161#endregion
162
163#region EventHandlers
164 public void RegisterCapsEventHandler(UUID agentID, Caps caps) { }
165 public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { }
166#endregion
167
168 private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs)
169 {
170 String result = urlSkel;
171
172 foreach (KeyValuePair<String,String> kvp in subs)
173 {
174 result = result.Replace(kvp.Key,kvp.Value);
175 }
176
177 return result;
178 }
179 }
180} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 7422d94..9a8164c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
153 { "Value", flags.ToString() } 153 { "Value", flags.ToString() }
154 }; 154 };
155 155
156 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 156 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
157 bool success = response["Success"].AsBoolean(); 157 bool success = response["Success"].AsBoolean();
158 158
159 if (!success) 159 if (!success)
@@ -180,7 +180,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
180 { "Key", friend } 180 { "Key", friend }
181 }; 181 };
182 182
183 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 183 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
184 bool success = response["Success"].AsBoolean(); 184 bool success = response["Success"].AsBoolean();
185 185
186 if (!success) 186 if (!success)
@@ -200,7 +200,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
200 { "Type", "Friend" } 200 { "Type", "Friend" }
201 }; 201 };
202 202
203 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 203 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
204 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 204 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
205 { 205 {
206 return (OSDArray)response["Entries"]; 206 return (OSDArray)response["Entries"];
@@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
221 { "Type", "Friend" } 221 { "Type", "Friend" }
222 }; 222 };
223 223
224 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 224 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
225 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 225 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
226 { 226 {
227 return (OSDArray)response["Entries"]; 227 return (OSDArray)response["Entries"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
index 847319c..a35d749 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs
@@ -26,8 +26,122 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Collections.Specialized;
31using System.Reflection;
32using log4net;
29using Mono.Addins; 33using Mono.Addins;
30using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces;
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
31 41
32[assembly: Addin("SimianGrid", "1.0")] 42[assembly: Addin("SimianGrid", OpenSim.VersionInfo.VersionNumber)]
33[assembly: AddinDependency("OpenSim", "0.5")] 43[assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
44
45namespace OpenSim.Services.Connectors.SimianGrid
46{
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")]
48 public class SimianGrid : ISharedRegionModule
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private IConfig m_config = null;
53
54 private String m_simianURL;
55
56#region IRegionModule Members
57
58 public string Name
59 {
60 get { return this.GetType().Name; }
61 }
62
63 public void Initialise(IConfigSource config)
64 {
65 try
66 {
67 m_config = config.Configs["SimianGrid"];
68
69 if (m_config != null)
70 {
71 m_simianURL = m_config.GetString("SimianServiceURL");
72 if (String.IsNullOrEmpty(m_simianURL))
73 {
74 // m_log.DebugFormat("[SimianGrid] service URL is not defined");
75 return;
76 }
77
78 InitialiseSimCap();
79 SimulatorCapability = SimulatorCapability.Trim();
80 m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
81 }
82 }
83 catch (Exception e)
84 {
85 m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
86 return;
87 }
88 }
89
90 public void PostInitialise() { }
91 public void Close() { }
92 public void AddRegion(Scene scene) { }
93 public void RemoveRegion(Scene scene) { }
94 public void RegionLoaded(Scene scene) { }
95
96 public Type ReplaceableInterface
97 {
98 get { return null; }
99 }
100
101 ///<summary>
102 /// Try a variety of methods for finding the simian simulator capability; first check the
103 /// configuration itself, then look for a file that contains the cap, then finally look
104 /// for an environment variable that contains it.
105 ///</summary>
106 private void InitialiseSimCap()
107 {
108 if (m_config.Contains("SimulatorCapability"))
109 {
110 SimulatorCapability = m_config.GetString("SimulatorCapability");
111 return;
112 }
113
114 if (m_config.Contains("SimulatorCapabilityFile"))
115 {
116 String filename = m_config.GetString("SimulatorCapabilityFile");
117 if (System.IO.File.Exists(filename))
118 {
119 SimulatorCapability = System.IO.File.ReadAllText(filename);
120 return;
121 }
122 }
123
124 if (m_config.Contains("SimulatorCapabilityVariable"))
125 {
126 String envname = m_config.GetString("SimulatorCapabilityVariable");
127 String envvalue = System.Environment.GetEnvironmentVariable(envname);
128 if (envvalue != null)
129 {
130 SimulatorCapability = envvalue;
131 return;
132 }
133 }
134
135 m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability");
136 }
137
138#endregion
139
140 public static String SimulatorCapability = UUID.Zero.ToString();
141 public static OSDMap PostToService(string url, NameValueCollection data)
142 {
143 data["cap"] = SimulatorCapability;
144 return WebUtil.PostToService(url, data);
145 }
146 }
147} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
index 93fdae3..8375c95 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized;
30using System.Reflection; 31using System.Reflection;
31using System.Net; 32using System.Net;
32using System.IO; 33using System.IO;
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes;
43using OpenMetaverse; 44using OpenMetaverse;
44using OpenMetaverse.StructuredData; 45using OpenMetaverse.StructuredData;
45 46
46namespace OpenSim.Region.OptionalModules.Simian 47//namespace OpenSim.Region.OptionalModules.Simian
48namespace OpenSim.Services.Connectors.SimianGrid
47{ 49{
48 /// <summary> 50 /// <summary>
49 /// </summary> 51 /// </summary>
@@ -179,7 +181,6 @@ namespace OpenSim.Region.OptionalModules.Simian
179 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName); 181 m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName);
180 182
181 // Create a PNG map tile and upload it to the AddMapTile API 183 // Create a PNG map tile and upload it to the AddMapTile API
182 byte[] pngData = Utils.EmptyBytes;
183 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); 184 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
184 if (tileGenerator == null) 185 if (tileGenerator == null)
185 { 186 {
@@ -187,76 +188,79 @@ namespace OpenSim.Region.OptionalModules.Simian
187 return; 188 return;
188 } 189 }
189 190
190 using (Image mapTile = tileGenerator.CreateMapTile()) 191 using (Bitmap mapTile = tileGenerator.CreateMapTile())
191 {
192 using (MemoryStream stream = new MemoryStream())
193 {
194 mapTile.Save(stream, ImageFormat.Png);
195 pngData = stream.ToArray();
196 }
197 }
198
199 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
200 {
201 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
202 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
203 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
204 };
205
206 string errorMessage = null;
207 int tickstart = Util.EnvironmentTickCount();
208
209 // Make the remote storage request
210 try
211 { 192 {
212 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); 193 if (mapTile != null)
213 request.Timeout = 20000;
214 request.ReadWriteTimeout = 5000;
215
216 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
217 { 194 {
218 using (Stream responseStream = response.GetResponseStream()) 195 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
196 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
219 { 197 {
220 string responseStr = responseStream.GetStreamString(); 198 ConvertAndUploadMaptile(mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY);
221 OSD responseOSD = OSDParser.Deserialize(responseStr); 199 }
222 if (responseOSD.Type == OSDType.Map) 200 else
201 {
202 // For larger regions (varregion) we must cut the region image into legacy sized
203 // pieces since that is how the maptile system works.
204 // Note the assumption that varregions are always a multiple of legacy size.
205 for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
223 { 206 {
224 OSDMap responseMap = (OSDMap)responseOSD; 207 for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
225 if (responseMap["Success"].AsBoolean()) 208 {
226 return; 209 // Images are addressed from the upper left corner so have to do funny
210 // math to pick out the sub-tile since regions are numbered from
211 // the lower left.
212 Rectangle rect = new Rectangle(
213 (int)xx,
214 mapTile.Height - (int)yy - (int)Constants.RegionSize,
215 (int)Constants.RegionSize, (int)Constants.RegionSize);
227 216
228 errorMessage = "Upload failed: " + responseMap["Message"].AsString(); 217 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
229 } 218 {
230 else 219 uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize);
231 { 220 uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize);
232 errorMessage = "Response format was invalid:\n" + responseStr; 221
222 ConvertAndUploadMaptile(subMapTile, locX, locY);
223 }
224 }
233 } 225 }
234 } 226 }
235 } 227 }
236 } 228 else
237 catch (WebException we)
238 {
239 errorMessage = we.Message;
240 if (we.Status == WebExceptionStatus.ProtocolError)
241 { 229 {
242 HttpWebResponse webResponse = (HttpWebResponse)we.Response; 230 m_log.WarnFormat("[SIMIAN MAPTILE] Tile image generation failed");
243 errorMessage = String.Format("[{0}] {1}",
244 webResponse.StatusCode,webResponse.StatusDescription);
245 } 231 }
246 } 232 }
247 catch (Exception ex) 233
234 }
235
236 ///<summary>
237 ///
238 ///</summary>
239 private void ConvertAndUploadMaptile(Image mapTile, uint locX, uint locY)
240 {
241 //m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for location {0}, {1}", locX, locY);
242
243 byte[] pngData = Utils.EmptyBytes;
244 using (MemoryStream stream = new MemoryStream())
248 { 245 {
249 errorMessage = ex.Message; 246 mapTile.Save(stream, ImageFormat.Png);
247 pngData = stream.ToArray();
250 } 248 }
251 finally 249
250 NameValueCollection requestArgs = new NameValueCollection
251 {
252 { "RequestMethod", "xAddMapTile" },
253 { "X", locX.ToString() },
254 { "Y", locY.ToString() },
255 { "ContentType", "image/png" },
256 { "EncodedData", System.Convert.ToBase64String(pngData) }
257 };
258
259 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
260 if (! response["Success"].AsBoolean())
252 { 261 {
253 // This just dumps a warning for any operation that takes more than 100 ms 262 m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
254 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
255 m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
256 } 263 }
257
258 m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
259 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
260 } 264 }
261 } 265 }
262} \ No newline at end of file 266} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 038a4bf..b031f21 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 102 {
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 104 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
105 105
106 OSDMap extraData = new OSDMap 106 OSDMap extraData = new OSDMap
107 { 107 {
@@ -129,7 +129,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
129 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 129 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
130 }; 130 };
131 131
132 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 132 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
133 if (response["Success"].AsBoolean()) 133 if (response["Success"].AsBoolean())
134 return String.Empty; 134 return String.Empty;
135 else 135 else
@@ -145,7 +145,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
145 { "Enabled", "0" } 145 { "Enabled", "0" }
146 }; 146 };
147 147
148 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 148 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
149 bool success = response["Success"].AsBoolean(); 149 bool success = response["Success"].AsBoolean();
150 150
151 if (!success) 151 if (!success)
@@ -156,15 +156,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 156
157 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 157 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 { 158 {
159 const int NEIGHBOR_RADIUS = 128;
160
161 GridRegion region = GetRegionByUUID(scopeID, regionID); 159 GridRegion region = GetRegionByUUID(scopeID, regionID);
162 160
161 int NEIGHBOR_RADIUS = Math.Max(region.RegionSizeX, region.RegionSizeY) / 2;
162
163 if (region != null) 163 if (region != null)
164 { 164 {
165 List<GridRegion> regions = GetRegionRange(scopeID, 165 List<GridRegion> regions = GetRegionRange(scopeID,
166 region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + (int)Constants.RegionSize + NEIGHBOR_RADIUS, 166 region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS,
167 region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + (int)Constants.RegionSize + NEIGHBOR_RADIUS); 167 region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS);
168 168
169 for (int i = 0; i < regions.Count; i++) 169 for (int i = 0; i < regions.Count; i++)
170 { 170 {
@@ -192,7 +192,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
192 192
193 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); 193 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
194 194
195 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 195 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
196 if (response["Success"].AsBoolean()) 196 if (response["Success"].AsBoolean())
197 { 197 {
198 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); 198 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
@@ -220,7 +220,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
220 220
221 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); 221 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
222 222
223 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 223 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
224 if (response["Success"].AsBoolean()) 224 if (response["Success"].AsBoolean())
225 { 225 {
226 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); 226 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
@@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
229 else 229 else
230 { 230 {
231 // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", 231 // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
232 // x / Constants.RegionSize, y / Constants.RegionSize); 232 // Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
233 return null; 233 return null;
234 } 234 }
235 } 235 }
@@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
261 261
262 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); 262 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
263 263
264 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 264 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
265 if (response["Success"].AsBoolean()) 265 if (response["Success"].AsBoolean())
266 { 266 {
267 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 267 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
299 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); 299 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
300 300
301 301
302 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 302 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
303 if (response["Success"].AsBoolean()) 303 if (response["Success"].AsBoolean())
304 { 304 {
305 OSDArray array = response["Scenes"] as OSDArray; 305 OSDArray array = response["Scenes"] as OSDArray;
@@ -330,6 +330,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
330 return new List<GridRegion>(0); 330 return new List<GridRegion>(0);
331 } 331 }
332 332
333 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
334 {
335 // TODO: Allow specifying the default grid location
336 return GetDefaultRegions(scopeID);
337 }
338
333 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 339 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
334 { 340 {
335 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); 341 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);
@@ -350,7 +356,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
350 { "Enabled", "1" } 356 { "Enabled", "1" }
351 }; 357 };
352 358
353 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 359 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
354 if (response["Success"].AsBoolean()) 360 if (response["Success"].AsBoolean())
355 { 361 {
356 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 362 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -380,7 +386,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
380 386
381 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); 387 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
382 388
383 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 389 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
384 if (response["Success"].AsBoolean()) 390 if (response["Success"].AsBoolean())
385 { 391 {
386 OSDMap extraData = response["ExtraData"] as OSDMap; 392 OSDMap extraData = response["ExtraData"] as OSDMap;
@@ -396,6 +402,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
396 return -1; 402 return -1;
397 } 403 }
398 } 404 }
405
406 public Dictionary<string, object> GetExtraFeatures()
407 {
408 /// See SimulatorFeaturesModule - Need to get map, search and destination guide
409 Dictionary<string, object> extraFeatures = new Dictionary<string, object>();
410 return extraFeatures;
411 }
399 412
400 #endregion IGridService 413 #endregion IGridService
401 414
@@ -410,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
410 if (onlyEnabled) 423 if (onlyEnabled)
411 requestArgs["Enabled"] = "1"; 424 requestArgs["Enabled"] = "1";
412 425
413 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 426 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
414 if (response["Success"].AsBoolean()) 427 if (response["Success"].AsBoolean())
415 { 428 {
416 return ResponseToGridRegion(response); 429 return ResponseToGridRegion(response);
@@ -437,9 +450,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
437 region.RegionName = response["Name"].AsString(); 450 region.RegionName = response["Name"].AsString();
438 451
439 Vector3d minPosition = response["MinPosition"].AsVector3d(); 452 Vector3d minPosition = response["MinPosition"].AsVector3d();
453 Vector3d maxPosition = response["MaxPosition"].AsVector3d();
440 region.RegionLocX = (int)minPosition.X; 454 region.RegionLocX = (int)minPosition.X;
441 region.RegionLocY = (int)minPosition.Y; 455 region.RegionLocY = (int)minPosition.Y;
442 456
457 region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
458 region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
459
443 if ( ! extraData["HyperGrid"] ) { 460 if ( ! extraData["HyperGrid"] ) {
444 Uri httpAddress = response["Address"].AsUri(); 461 Uri httpAddress = response["Address"].AsUri();
445 region.ExternalHostName = httpAddress.Host; 462 region.ExternalHostName = httpAddress.Host;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index a391275..e793420 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -38,12 +38,14 @@ using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using PermissionMask = OpenSim.Framework.PermissionMask;
41 42
42namespace OpenSim.Services.Connectors.SimianGrid 43namespace OpenSim.Services.Connectors.SimianGrid
43{ 44{
44 /// <summary> 45 /// <summary>
45 /// Permissions bitflags 46 /// Permissions bitflags
46 /// </summary> 47 /// </summary>
48 /*
47 [Flags] 49 [Flags]
48 public enum PermissionMask : uint 50 public enum PermissionMask : uint
49 { 51 {
@@ -55,6 +57,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
55 Damage = 1 << 20, 57 Damage = 1 << 20,
56 All = 0x7FFFFFFF 58 All = 0x7FFFFFFF
57 } 59 }
60 */
58 61
59 /// <summary> 62 /// <summary>
60 /// Connects avatar inventories to the SimianGrid backend 63 /// Connects avatar inventories to the SimianGrid backend
@@ -71,6 +74,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
71// private object m_gestureSyncRoot = new object(); 74// private object m_gestureSyncRoot = new object();
72 private bool m_Enabled = false; 75 private bool m_Enabled = false;
73 76
77 private const double CACHE_EXPIRATION_SECONDS = 20.0;
78 private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache;
79
74 #region ISharedRegionModule 80 #region ISharedRegionModule
75 81
76 public Type ReplaceableInterface { get { return null; } } 82 public Type ReplaceableInterface { get { return null; } }
@@ -96,6 +102,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
96 url = url + '/'; 102 url = url + '/';
97 m_serverUrl = url; 103 m_serverUrl = url;
98 104
105 if (m_ItemCache == null)
106 m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
107
99 } 108 }
100 109
101 public void Initialise(IConfigSource source) 110 public void Initialise(IConfigSource source)
@@ -129,6 +138,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
129 { 138 {
130 m_userServerUrl = serviceUrl; 139 m_userServerUrl = serviceUrl;
131 m_Enabled = true; 140 m_Enabled = true;
141 if (m_ItemCache == null)
142 m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>();
132 } 143 }
133 } 144 }
134 } 145 }
@@ -153,7 +164,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
153 { "OwnerID", userID.ToString() } 164 { "OwnerID", userID.ToString() }
154 }; 165 };
155 166
156 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 167 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
157 bool success = response["Success"].AsBoolean(); 168 bool success = response["Success"].AsBoolean();
158 169
159 if (!success) 170 if (!success)
@@ -179,7 +190,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
179 { "ChildrenOnly", "0" } 190 { "ChildrenOnly", "0" }
180 }; 191 };
181 192
182 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 193 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
183 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 194 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
184 { 195 {
185 OSDArray items = (OSDArray)response["Items"]; 196 OSDArray items = (OSDArray)response["Items"];
@@ -194,37 +205,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
194 } 205 }
195 206
196 /// <summary> 207 /// <summary>
197 /// Synchronous inventory fetch.
198 /// </summary>
199 /// <param name="userID"></param>
200 /// <returns></returns>
201 [Obsolete]
202 public InventoryCollection GetUserInventory(UUID userID)
203 {
204 m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID);
205
206 InventoryCollection inventory = new InventoryCollection();
207 inventory.UserID = userID;
208 inventory.Folders = new List<InventoryFolderBase>();
209 inventory.Items = new List<InventoryItemBase>();
210
211 return inventory;
212 }
213
214 /// <summary>
215 /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the
216 /// inventory has been received
217 /// </summary>
218 /// <param name="userID"></param>
219 /// <param name="callback"></param>
220 [Obsolete]
221 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
222 {
223 m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID);
224 callback(new List<InventoryFolderImpl>(0), new List<InventoryItemBase>(0));
225 }
226
227 /// <summary>
228 /// Retrieve the root inventory folder for the given user. 208 /// Retrieve the root inventory folder for the given user.
229 /// </summary> 209 /// </summary>
230 /// <param name="userID"></param> 210 /// <param name="userID"></param>
@@ -241,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
241 { "ChildrenOnly", "1" } 221 { "ChildrenOnly", "1" }
242 }; 222 };
243 223
244 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 224 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
245 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 225 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
246 { 226 {
247 OSDArray items = (OSDArray)response["Items"]; 227 OSDArray items = (OSDArray)response["Items"];
@@ -260,7 +240,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
260 /// <param name="userID"></param> 240 /// <param name="userID"></param>
261 /// <param name="type"></param> 241 /// <param name="type"></param>
262 /// <returns></returns> 242 /// <returns></returns>
263 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 243 public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
264 { 244 {
265 string contentType = SLUtil.SLAssetTypeToContentType((int)type); 245 string contentType = SLUtil.SLAssetTypeToContentType((int)type);
266 246
@@ -271,7 +251,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
271 { "OwnerID", userID.ToString() } 251 { "OwnerID", userID.ToString() }
272 }; 252 };
273 253
274 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 254 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
275 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) 255 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap)
276 { 256 {
277 OSDMap folder = (OSDMap)response["Folder"]; 257 OSDMap folder = (OSDMap)response["Folder"];
@@ -299,6 +279,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
299 /// <returns></returns> 279 /// <returns></returns>
300 public InventoryItemBase GetItem(InventoryItemBase item) 280 public InventoryItemBase GetItem(InventoryItemBase item)
301 { 281 {
282 InventoryItemBase retrieved = null;
283 if (m_ItemCache.TryGetValue(item.ID, out retrieved))
284 return retrieved;
285
302 NameValueCollection requestArgs = new NameValueCollection 286 NameValueCollection requestArgs = new NameValueCollection
303 { 287 {
304 { "RequestMethod", "GetInventoryNode" }, 288 { "RequestMethod", "GetInventoryNode" },
@@ -309,7 +293,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
309 { "ChildrenOnly", "1" } 293 { "ChildrenOnly", "1" }
310 }; 294 };
311 295
312 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 296 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
313 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 297 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
314 { 298 {
315 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); 299 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]);
@@ -320,7 +304,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
320 for (int i = 0; i < items.Count; i++) 304 for (int i = 0; i < items.Count; i++)
321 { 305 {
322 if (items[i].ID == item.ID) 306 if (items[i].ID == item.ID)
323 return items[i]; 307 {
308 retrieved = items[i];
309 m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS);
310 return retrieved;
311 }
324 } 312 }
325 } 313 }
326 } 314 }
@@ -329,6 +317,21 @@ namespace OpenSim.Services.Connectors.SimianGrid
329 return null; 317 return null;
330 } 318 }
331 319
320 public InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs)
321 {
322 InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length];
323 int i = 0;
324 InventoryItemBase item = new InventoryItemBase();
325 item.Owner = principalID;
326 foreach (UUID id in itemIDs)
327 {
328 item.ID = id;
329 result[i++] = GetItem(item);
330 }
331
332 return result;
333 }
334
332 /// <summary> 335 /// <summary>
333 /// Get a folder, given by its UUID 336 /// Get a folder, given by its UUID
334 /// </summary> 337 /// </summary>
@@ -346,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
346 { "ChildrenOnly", "1" } 349 { "ChildrenOnly", "1" }
347 }; 350 };
348 351
349 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 352 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
350 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
351 { 354 {
352 OSDArray items = (OSDArray)response["Items"]; 355 OSDArray items = (OSDArray)response["Items"];
@@ -368,7 +371,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
368 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 371 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
369 { 372 {
370 InventoryCollection inventory = new InventoryCollection(); 373 InventoryCollection inventory = new InventoryCollection();
371 inventory.UserID = userID; 374 inventory.OwnerID = userID;
372 375
373 NameValueCollection requestArgs = new NameValueCollection 376 NameValueCollection requestArgs = new NameValueCollection
374 { 377 {
@@ -380,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
380 { "ChildrenOnly", "1" } 383 { "ChildrenOnly", "1" }
381 }; 384 };
382 385
383 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 386 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
384 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 387 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
385 { 388 {
386 OSDArray items = (OSDArray)response["Items"]; 389 OSDArray items = (OSDArray)response["Items"];
@@ -399,6 +402,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
399 return inventory; 402 return inventory;
400 } 403 }
401 404
405 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
406 {
407 InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
408 int i = 0;
409 foreach (UUID fid in folderIDs)
410 {
411 invColl[i++] = GetFolderContent(principalID, fid);
412 }
413
414 return invColl;
415 }
416
402 /// <summary> 417 /// <summary>
403 /// Gets the items inside a folder 418 /// Gets the items inside a folder
404 /// </summary> 419 /// </summary>
@@ -408,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
408 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 423 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
409 { 424 {
410 InventoryCollection inventory = new InventoryCollection(); 425 InventoryCollection inventory = new InventoryCollection();
411 inventory.UserID = userID; 426 inventory.OwnerID = userID;
412 427
413 NameValueCollection requestArgs = new NameValueCollection 428 NameValueCollection requestArgs = new NameValueCollection
414 { 429 {
@@ -420,7 +435,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
420 { "ChildrenOnly", "1" } 435 { "ChildrenOnly", "1" }
421 }; 436 };
422 437
423 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 438 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
424 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 439 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
425 { 440 {
426 OSDArray items = (OSDArray)response["Items"]; 441 OSDArray items = (OSDArray)response["Items"];
@@ -451,7 +466,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
451 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } 466 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) }
452 }; 467 };
453 468
454 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 469 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
455 bool success = response["Success"].AsBoolean(); 470 bool success = response["Success"].AsBoolean();
456 471
457 if (!success) 472 if (!success)
@@ -515,7 +530,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
515 { "ItemID", itemID.ToString() } 530 { "ItemID", itemID.ToString() }
516 }; 531 };
517 532
518 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 533 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
519 bool success = response["Success"].AsBoolean(); 534 bool success = response["Success"].AsBoolean();
520 535
521 if (!success) 536 if (!success)
@@ -543,7 +558,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
543 { "FolderID", folder.ID.ToString() } 558 { "FolderID", folder.ID.ToString() }
544 }; 559 };
545 560
546 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 561 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
547 bool success = response["Success"].AsBoolean(); 562 bool success = response["Success"].AsBoolean();
548 563
549 if (!success) 564 if (!success)
@@ -565,7 +580,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
565 // A folder of UUID.Zero means we need to find the most appropriate home for this item 580 // A folder of UUID.Zero means we need to find the most appropriate home for this item
566 if (item.Folder == UUID.Zero) 581 if (item.Folder == UUID.Zero)
567 { 582 {
568 InventoryFolderBase folder = GetFolderForType(item.Owner, (AssetType)item.AssetType); 583 InventoryFolderBase folder = null;
584 if (Enum.IsDefined(typeof(FolderType), (sbyte)item.AssetType))
585 folder = GetFolderForType(item.Owner, (FolderType)item.AssetType);
569 if (folder != null && folder.ID != UUID.Zero) 586 if (folder != null && folder.ID != UUID.Zero)
570 item.Folder = folder.ID; 587 item.Folder = folder.ID;
571 else 588 else
@@ -620,7 +637,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
620 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 637 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
621 }; 638 };
622 639
623 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 640 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
624 bool success = response["Success"].AsBoolean(); 641 bool success = response["Success"].AsBoolean();
625 642
626 if (!success) 643 if (!success)
@@ -844,7 +861,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
844 { "Items", String.Join(",", itemIDs) } 861 { "Items", String.Join(",", itemIDs) }
845 }; 862 };
846 863
847 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 864 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
848 bool success = response["Success"].AsBoolean(); 865 bool success = response["Success"].AsBoolean();
849 866
850 if (!success) 867 if (!success)
@@ -882,7 +899,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
882 { "UserID", userID.ToString() } 899 { "UserID", userID.ToString() }
883 }; 900 };
884 901
885 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 902 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
886 if (response["Success"].AsBoolean()) 903 if (response["Success"].AsBoolean())
887 { 904 {
888 OSDMap user = response["User"] as OSDMap; 905 OSDMap user = response["User"] as OSDMap;
@@ -913,7 +930,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
913 { "Gestures", OSDParser.SerializeJsonString(gestures) } 930 { "Gestures", OSDParser.SerializeJsonString(gestures) }
914 }; 931 };
915 932
916 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 933 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
917 if (!response["Success"].AsBoolean()) 934 if (!response["Success"].AsBoolean())
918 { 935 {
919 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + 936 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " +
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 854bea4..211b775 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 public void PostInitialise() { } 65 public void PostInitialise() { }
66 public void Close() { } 66 public void Close() { }
67 67
68 public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); } 68 public SimianPresenceServiceConnector() { }
69 public string Name { get { return "SimianPresenceServiceConnector"; } } 69 public string Name { get { return "SimianPresenceServiceConnector"; } }
70 public void AddRegion(Scene scene) 70 public void AddRegion(Scene scene)
71 { 71 {
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
122 serviceUrl = serviceUrl + '/'; 122 serviceUrl = serviceUrl + '/';
123 m_serverUrl = serviceUrl; 123 m_serverUrl = serviceUrl;
124 m_activityDetector = new SimianActivityDetector(this);
124 m_Enabled = true; 125 m_Enabled = true;
125 } 126 }
126 } 127 }
@@ -137,17 +138,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
137 userID, sessionID, secureSessionID); 138 userID, sessionID, secureSessionID);
138 139
139 NameValueCollection requestArgs = new NameValueCollection 140 NameValueCollection requestArgs = new NameValueCollection
140 { 141 {
141 { "RequestMethod", "AddSession" }, 142 { "RequestMethod", "AddSession" },
142 { "UserID", userID.ToString() } 143 { "UserID", userID.ToString() }
143 }; 144 };
145
144 if (sessionID != UUID.Zero) 146 if (sessionID != UUID.Zero)
145 { 147 {
146 requestArgs["SessionID"] = sessionID.ToString(); 148 requestArgs["SessionID"] = sessionID.ToString();
147 requestArgs["SecureSessionID"] = secureSessionID.ToString(); 149 requestArgs["SecureSessionID"] = secureSessionID.ToString();
148 } 150 }
149 151
150 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 152 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
151 bool success = response["Success"].AsBoolean(); 153 bool success = response["Success"].AsBoolean();
152 154
153 if (!success) 155 if (!success)
@@ -158,15 +160,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
158 160
159 public bool LogoutAgent(UUID sessionID) 161 public bool LogoutAgent(UUID sessionID)
160 { 162 {
161// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 163 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
162 164
163 NameValueCollection requestArgs = new NameValueCollection 165 NameValueCollection requestArgs = new NameValueCollection
164 { 166 {
165 { "RequestMethod", "RemoveSession" }, 167 { "RequestMethod", "RemoveSession" },
166 { "SessionID", sessionID.ToString() } 168 { "SessionID", sessionID.ToString() }
167 }; 169 };
168 170
169 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 171 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
170 bool success = response["Success"].AsBoolean(); 172 bool success = response["Success"].AsBoolean();
171 173
172 if (!success) 174 if (!success)
@@ -177,15 +179,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
177 179
178 public bool LogoutRegionAgents(UUID regionID) 180 public bool LogoutRegionAgents(UUID regionID)
179 { 181 {
180// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); 182 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
181 183
182 NameValueCollection requestArgs = new NameValueCollection 184 NameValueCollection requestArgs = new NameValueCollection
183 { 185 {
184 { "RequestMethod", "RemoveSessions" }, 186 { "RequestMethod", "RemoveSessions" },
185 { "SceneID", regionID.ToString() } 187 { "SceneID", regionID.ToString() }
186 }; 188 };
187 189
188 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 190 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
189 bool success = response["Success"].AsBoolean(); 191 bool success = response["Success"].AsBoolean();
190 192
191 if (!success) 193 if (!success)
@@ -202,49 +204,46 @@ namespace OpenSim.Services.Connectors.SimianGrid
202 204
203 public PresenceInfo GetAgent(UUID sessionID) 205 public PresenceInfo GetAgent(UUID sessionID)
204 { 206 {
205// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID); 207 OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID);
206 208 if (sessionResponse == null)
207 NameValueCollection requestArgs = new NameValueCollection
208 {
209 { "RequestMethod", "GetSession" },
210 { "SessionID", sessionID.ToString() }
211 };
212
213 OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
214 if (sessionResponse["Success"].AsBoolean())
215 { 209 {
216 UUID userID = sessionResponse["UserID"].AsUUID(); 210 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
217 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 211 return null;
218
219 requestArgs = new NameValueCollection
220 {
221 { "RequestMethod", "GetUser" },
222 { "UserID", userID.ToString() }
223 };
224
225 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
226 if (userResponse["Success"].AsBoolean())
227 return ResponseToPresenceInfo(sessionResponse, userResponse);
228 else
229 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
230 } 212 }
231 else 213
214 UUID userID = sessionResponse["UserID"].AsUUID();
215 OSDMap userResponse = GetUserData(userID);
216 if (userResponse == null)
232 { 217 {
233 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString()); 218 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
219 return null;
234 } 220 }
235 221
236 return null; 222 return ResponseToPresenceInfo(sessionResponse);
237 } 223 }
238 224
239 public PresenceInfo[] GetAgents(string[] userIDs) 225 public PresenceInfo[] GetAgents(string[] userIDs)
240 { 226 {
241 List<PresenceInfo> presences = new List<PresenceInfo>(userIDs.Length); 227 List<PresenceInfo> presences = new List<PresenceInfo>();
228
229 NameValueCollection requestArgs = new NameValueCollection
230 {
231 { "RequestMethod", "GetSessions" },
232 { "UserIDList", String.Join(",",userIDs) }
233 };
242 234
243 for (int i = 0; i < userIDs.Length; i++) 235 OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs);
236 if (! sessionListResponse["Success"].AsBoolean())
244 { 237 {
245 UUID userID; 238 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
246 if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero) 239 return null;
247 presences.AddRange(GetSessions(userID)); 240 }
241
242 OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
243 for (int i = 0; i < sessionList.Count; i++)
244 {
245 OSDMap sessionInfo = sessionList[i] as OSDMap;
246 presences.Add(ResponseToPresenceInfo(sessionInfo));
248 } 247 }
249 248
250 return presences.ToArray(); 249 return presences.ToArray();
@@ -262,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
262 261
263 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 262 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
264 { 263 {
265// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); 264 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
266 265
267 // Remove the session to mark this user offline 266 // Remove the session to mark this user offline
268 if (!LogoutAgent(sessionID)) 267 if (!LogoutAgent(sessionID))
@@ -270,13 +269,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
270 269
271 // Save our last position as user data 270 // Save our last position as user data
272 NameValueCollection requestArgs = new NameValueCollection 271 NameValueCollection requestArgs = new NameValueCollection
273 { 272 {
274 { "RequestMethod", "AddUserData" }, 273 { "RequestMethod", "AddUserData" },
275 { "UserID", userID.ToString() }, 274 { "UserID", userID.ToString() },
276 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } 275 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
277 }; 276 };
278 277
279 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 278 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
280 bool success = response["Success"].AsBoolean(); 279 bool success = response["Success"].AsBoolean();
281 280
282 if (!success) 281 if (!success)
@@ -287,16 +286,16 @@ namespace OpenSim.Services.Connectors.SimianGrid
287 286
288 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
289 { 288 {
290// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 289 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
291 290
292 NameValueCollection requestArgs = new NameValueCollection 291 NameValueCollection requestArgs = new NameValueCollection
293 { 292 {
294 { "RequestMethod", "AddUserData" }, 293 { "RequestMethod", "AddUserData" },
295 { "UserID", userID.ToString() }, 294 { "UserID", userID.ToString() },
296 { "HomeLocation", SerializeLocation(regionID, position, lookAt) } 295 { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
297 }; 296 };
298 297
299 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 298 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
300 bool success = response["Success"].AsBoolean(); 299 bool success = response["Success"].AsBoolean();
301 300
302 if (!success) 301 if (!success)
@@ -312,24 +311,19 @@ namespace OpenSim.Services.Connectors.SimianGrid
312 311
313 public GridUserInfo GetGridUserInfo(string user) 312 public GridUserInfo GetGridUserInfo(string user)
314 { 313 {
315// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); 314 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316 315
317 UUID userID = new UUID(user); 316 UUID userID = new UUID(user);
318// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 317 OSDMap userResponse = GetUserData(userID);
319 318
320 NameValueCollection requestArgs = new NameValueCollection 319 if (userResponse == null)
321 { 320 {
322 { "RequestMethod", "GetUser" }, 321 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID);
323 { "UserID", userID.ToString() } 322 }
324 };
325 323
326 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); 324 // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null.
327 if (userResponse["Success"].AsBoolean()) 325 return ResponseToGridUserInfo(userResponse);
328 return ResponseToGridUserInfo(userResponse);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331 326
332 return null;
333 } 327 }
334 328
335 #endregion 329 #endregion
@@ -338,67 +332,51 @@ namespace OpenSim.Services.Connectors.SimianGrid
338 332
339 private OSDMap GetUserData(UUID userID) 333 private OSDMap GetUserData(UUID userID)
340 { 334 {
341// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 335 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
342 336
343 NameValueCollection requestArgs = new NameValueCollection 337 NameValueCollection requestArgs = new NameValueCollection
344 { 338 {
345 { "RequestMethod", "GetUser" }, 339 { "RequestMethod", "GetUser" },
346 { "UserID", userID.ToString() } 340 { "UserID", userID.ToString() }
347 }; 341 };
348 342
349 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 343 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
350 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 344 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
351 return response; 345 return response;
352 else
353 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString());
354 346
347 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString());
355 return null; 348 return null;
356 } 349 }
357 350
358 private List<PresenceInfo> GetSessions(UUID userID) 351 private OSDMap GetSessionDataFromSessionID(UUID sessionID)
359 { 352 {
360 List<PresenceInfo> presences = new List<PresenceInfo>(1); 353 NameValueCollection requestArgs = new NameValueCollection
361
362 OSDMap userResponse = GetUserData(userID);
363 if (userResponse != null)
364 {
365// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID);
366
367 NameValueCollection requestArgs = new NameValueCollection
368 { 354 {
369 { "RequestMethod", "GetSession" }, 355 { "RequestMethod", "GetSession" },
370 { "UserID", userID.ToString() } 356 { "SessionID", sessionID.ToString() }
371 }; 357 };
372 358
373 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 359 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
374 if (response["Success"].AsBoolean()) 360 if (response["Success"].AsBoolean())
375 { 361 return response;
376 PresenceInfo presence = ResponseToPresenceInfo(response, userResponse);
377 if (presence != null)
378 presences.Add(presence);
379 }
380// else
381// {
382// m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString());
383// }
384 }
385 362
386 return presences; 363 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString());
364 return null;
387 } 365 }
388 366
389 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 367 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
390 { 368 {
391 // Save our current location as session data 369 // Save our current location as session data
392 NameValueCollection requestArgs = new NameValueCollection 370 NameValueCollection requestArgs = new NameValueCollection
393 { 371 {
394 { "RequestMethod", "UpdateSession" }, 372 { "RequestMethod", "UpdateSession" },
395 { "SessionID", sessionID.ToString() }, 373 { "SessionID", sessionID.ToString() },
396 { "SceneID", regionID.ToString() }, 374 { "SceneID", regionID.ToString() },
397 { "ScenePosition", lastPosition.ToString() }, 375 { "ScenePosition", lastPosition.ToString() },
398 { "SceneLookAt", lastLookAt.ToString() } 376 { "SceneLookAt", lastLookAt.ToString() }
399 }; 377 };
400 378
401 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 379 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
402 bool success = response["Success"].AsBoolean(); 380 bool success = response["Success"].AsBoolean();
403 381
404 if (!success) 382 if (!success)
@@ -407,7 +385,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
407 return success; 385 return success;
408 } 386 }
409 387
410 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) 388 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse)
411 { 389 {
412 if (sessionResponse == null) 390 if (sessionResponse == null)
413 return null; 391 return null;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
index bd8069f..8fc766d 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
@@ -392,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
392 { "UserID", client.AgentId.ToString() } 392 { "UserID", client.AgentId.ToString() }
393 }; 393 };
394 394
395 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 395 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
396 string email = response["Email"].AsString(); 396 string email = response["Email"].AsString();
397 397
398 if (!response["Success"].AsBoolean()) 398 if (!response["Success"].AsBoolean())
@@ -425,7 +425,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
425 estate.EstateID, admin.Name); 425 estate.EstateID, admin.Name);
426 426
427 estate.EstateOwner = admin.PrincipalID; 427 estate.EstateOwner = admin.PrincipalID;
428 estate.Save(); 428 scene.EstateDataService.StoreEstateSettings(estate);
429 } 429 }
430 else 430 else
431 { 431 {
@@ -443,7 +443,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
443 { key, OSDParser.SerializeJsonString(value) } 443 { key, OSDParser.SerializeJsonString(value) }
444 }; 444 };
445 445
446 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 446 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
447 bool success = response["Success"].AsBoolean(); 447 bool success = response["Success"].AsBoolean();
448 448
449 if (!success) 449 if (!success)
@@ -462,7 +462,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
462 { "UserID", userID.ToString() } 462 { "UserID", userID.ToString() }
463 }; 463 };
464 464
465 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 465 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
466 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 466 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
467 { 467 {
468 return (OSDMap)response["User"]; 468 return (OSDMap)response["User"];
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 6e32b3a..698c4c0 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -165,7 +165,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
165 { "NameQuery", query } 165 { "NameQuery", query }
166 }; 166 };
167 167
168 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 168 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
169 if (response["Success"].AsBoolean()) 169 if (response["Success"].AsBoolean())
170 { 170 {
171 OSDArray array = response["Users"] as OSDArray; 171 OSDArray array = response["Users"] as OSDArray;
@@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
191 return accounts; 191 return accounts;
192 } 192 }
193 193
194 public void InvalidateCache(UUID userID)
195 {
196 m_accountCache.Remove(userID);
197 }
198
194 public bool StoreUserAccount(UserAccount data) 199 public bool StoreUserAccount(UserAccount data)
195 { 200 {
196// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); 201// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
@@ -204,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
204 { "AccessLevel", data.UserLevel.ToString() } 209 { "AccessLevel", data.UserLevel.ToString() }
205 }; 210 };
206 211
207 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 212 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
208 213
209 if (response["Success"].AsBoolean()) 214 if (response["Success"].AsBoolean())
210 { 215 {
@@ -219,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
219 { "UserTitle", data.UserTitle } 224 { "UserTitle", data.UserTitle }
220 }; 225 };
221 226
222 response = WebUtil.PostToService(m_serverUrl, requestArgs); 227 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
223 bool success = response["Success"].AsBoolean(); 228 bool success = response["Success"].AsBoolean();
224 229
225 if (success) 230 if (success)
@@ -252,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
252 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; 257 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)";
253// m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); 258// m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue);
254 259
255 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 260 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
256 if (response["Success"].AsBoolean()) 261 if (response["Success"].AsBoolean())
257 { 262 {
258 OSDMap user = response["User"] as OSDMap; 263 OSDMap user = response["User"] as OSDMap;
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 57f2ffa..cea870b 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -79,11 +79,37 @@ namespace OpenSim.Services.Connectors.Simulation
79 return "agent/"; 79 return "agent/";
80 } 80 }
81 81
82 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 82 protected virtual void PackData(OSDMap args, GridRegion source, AgentCircuitData aCircuit, GridRegion destination, uint flags)
83 { 83 {
84 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); 84 if (source != null)
85 85 {
86 args["source_x"] = OSD.FromString(source.RegionLocX.ToString());
87 args["source_y"] = OSD.FromString(source.RegionLocY.ToString());
88 args["source_name"] = OSD.FromString(source.RegionName);
89 args["source_uuid"] = OSD.FromString(source.RegionID.ToString());
90 if (!String.IsNullOrEmpty(source.RawServerURI))
91 args["source_server_uri"] = OSD.FromString(source.RawServerURI);
92 }
93
94 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
95 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
96 args["destination_name"] = OSD.FromString(destination.RegionName);
97 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
98 args["teleport_flags"] = OSD.FromString(flags.ToString());
99 }
100
101 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
102 {
103 string tmp = String.Empty;
104 return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason);
105 }
106
107 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
108 {
109 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
86 reason = String.Empty; 110 reason = String.Empty;
111 myipaddress = String.Empty;
112
87 if (destination == null) 113 if (destination == null)
88 { 114 {
89 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); 115 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
@@ -95,12 +121,7 @@ namespace OpenSim.Services.Connectors.Simulation
95 try 121 try
96 { 122 {
97 OSDMap args = aCircuit.PackAgentCircuitData(); 123 OSDMap args = aCircuit.PackAgentCircuitData();
98 124 PackData(args, source, aCircuit, destination, flags);
99 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
100 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
101 args["destination_name"] = OSD.FromString(destination.RegionName);
102 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
103 args["teleport_flags"] = OSD.FromString(flags.ToString());
104 125
105 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 126 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
106 bool success = result["success"].AsBoolean(); 127 bool success = result["success"].AsBoolean();
@@ -110,11 +131,12 @@ namespace OpenSim.Services.Connectors.Simulation
110 131
111 reason = data["reason"].AsString(); 132 reason = data["reason"].AsString();
112 success = data["success"].AsBoolean(); 133 success = data["success"].AsBoolean();
134 myipaddress = data["your_ip"].AsString();
113 return success; 135 return success;
114 } 136 }
115 137
116 // Try the old version, uncompressed 138 // Try the old version, uncompressed
117 result = WebUtil.PostToService(uri, args, 30000); 139 result = WebUtil.PostToService(uri, args, 30000, false);
118 140
119 if (result["Success"].AsBoolean()) 141 if (result["Success"].AsBoolean())
120 { 142 {
@@ -124,6 +146,7 @@ namespace OpenSim.Services.Connectors.Simulation
124 146
125 reason = data["reason"].AsString(); 147 reason = data["reason"].AsString();
126 success = data["success"].AsBoolean(); 148 success = data["success"].AsBoolean();
149 myipaddress = data["your_ip"].AsString();
127 m_log.WarnFormat( 150 m_log.WarnFormat(
128 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); 151 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
129 return success; 152 return success;
@@ -228,7 +251,7 @@ namespace OpenSim.Services.Connectors.Simulation
228 /// </summary> 251 /// </summary>
229 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) 252 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout)
230 { 253 {
231 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start"); 254 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
232 255
233 // Eventually, we want to use a caps url instead of the agentID 256 // Eventually, we want to use a caps url instead of the agentID
234 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; 257 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/";
@@ -258,48 +281,10 @@ namespace OpenSim.Services.Connectors.Simulation
258 return false; 281 return false;
259 } 282 }
260 283
261 /// <summary>
262 /// Not sure what sequence causes this function to be invoked. The only calling
263 /// path is through the GET method
264 /// </summary>
265 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
266 {
267 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start");
268
269 agent = null;
270
271 // Eventually, we want to use a caps url instead of the agentID
272 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
273
274 try
275 {
276 OSDMap result = WebUtil.GetFromService(uri, 10000);
277 if (result["Success"].AsBoolean())
278 {
279 // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString());
280 OSDMap args = (OSDMap)result["_Result"];
281 if (args != null)
282 {
283 agent = new CompleteAgentData();
284 agent.Unpack(args, null);
285 return true;
286 }
287 }
288 }
289 catch (Exception e)
290 {
291 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString());
292 }
293
294 return false;
295 }
296 284
297 /// <summary> 285 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> featuresAvailable, EntityTransferContext ctx, out string reason)
298 /// </summary>
299 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
300 { 286 {
301 reason = "Failed to contact destination"; 287 reason = "Failed to contact destination";
302 version = "Unknown";
303 288
304 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position); 289 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);
305 290
@@ -307,14 +292,32 @@ namespace OpenSim.Services.Connectors.Simulation
307 if (ext == null) return false; 292 if (ext == null) return false;
308 293
309 // Eventually, we want to use a caps url instead of the agentID 294 // Eventually, we want to use a caps url instead of the agentID
310 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; 295 string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";
311 296
312 OSDMap request = new OSDMap(); 297 OSDMap request = new OSDMap();
298 request.Add("viaTeleport", OSD.FromBoolean(viaTeleport));
313 request.Add("position", OSD.FromString(position.ToString())); 299 request.Add("position", OSD.FromString(position.ToString()));
300 // To those who still understad this field, we're telling them
301 // the lowest version just to be safe
302 request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin)));
303 // New simulation service negotiation
304 request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin));
305 request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax));
306 request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin));
307 request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax));
308
309 OSDArray features = new OSDArray();
310 foreach (UUID feature in featuresAvailable)
311 features.Add(OSD.FromString(feature.ToString()));
312
313 request.Add("features", features);
314
315 if (agentHomeURI != null)
316 request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
314 317
315 try 318 try
316 { 319 {
317 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false); 320 OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false);
318 bool success = result["success"].AsBoolean(); 321 bool success = result["success"].AsBoolean();
319 if (result.ContainsKey("_Result")) 322 if (result.ContainsKey("_Result"))
320 { 323 {
@@ -325,15 +328,32 @@ namespace OpenSim.Services.Connectors.Simulation
325 success = data["success"]; 328 success = data["success"];
326 329
327 reason = data["reason"].AsString(); 330 reason = data["reason"].AsString();
328 if (data["version"] != null && data["version"].AsString() != string.Empty) 331 // We will need to plumb this and start sing the outbound version as well
329 version = data["version"].AsString(); 332 // TODO: lay the pipe for version plumbing
333 if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null)
334 {
335 ctx.InboundVersion = (float)data["negotiated_inbound_version"].AsReal();
336 ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal();
337 }
338 else if (data["version"] != null && data["version"].AsString() != string.Empty)
339 {
340 string versionString = data["version"].AsString();
341 String[] parts = versionString.Split(new char[] {'/'});
342 if (parts.Length > 1)
343 {
344 ctx.InboundVersion = float.Parse(parts[1]);
345 ctx.OutboundVersion = float.Parse(parts[1]);
346 }
347 }
348 if (data.ContainsKey("variable_wearables_count_supported"))
349 ctx.VariableWearablesSupported = true;
330 350
331 m_log.DebugFormat( 351 m_log.DebugFormat(
332 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3} ({4})", 352 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}",
333 uri, success, reason, version, data["version"].AsString()); 353 uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion);
334 } 354 }
335 355
336 if (!success) 356 if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f)
337 { 357 {
338 // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the 358 // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
339 // actual failure message 359 // actual failure message
@@ -359,6 +379,17 @@ namespace OpenSim.Services.Connectors.Simulation
359 return false; 379 return false;
360 } 380 }
361 381
382
383 featuresAvailable.Clear();
384
385 if (result.ContainsKey("features"))
386 {
387 OSDArray array = (OSDArray)result["features"];
388
389 foreach (OSD o in array)
390 featuresAvailable.Add(new UUID(o.AsString()));
391 }
392
362 return success; 393 return success;
363 } 394 }
364 catch (Exception e) 395 catch (Exception e)
@@ -377,7 +408,7 @@ namespace OpenSim.Services.Connectors.Simulation
377 408
378 try 409 try
379 { 410 {
380 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); 411 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
381 } 412 }
382 catch (Exception e) 413 catch (Exception e)
383 { 414 {
@@ -389,15 +420,14 @@ namespace OpenSim.Services.Connectors.Simulation
389 420
390 /// <summary> 421 /// <summary>
391 /// </summary> 422 /// </summary>
392 public bool CloseAgent(GridRegion destination, UUID id) 423 public bool CloseAgent(GridRegion destination, UUID id, string auth_code)
393 { 424 {
394// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); 425 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code;
395 426 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri);
396 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
397 427
398 try 428 try
399 { 429 {
400 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); 430 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false);
401 } 431 }
402 catch (Exception e) 432 catch (Exception e)
403 { 433 {
@@ -444,11 +474,18 @@ namespace OpenSim.Services.Connectors.Simulation
444 args["destination_name"] = OSD.FromString(destination.RegionName); 474 args["destination_name"] = OSD.FromString(destination.RegionName);
445 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 475 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
446 476
447 WebUtil.PostToService(uri, args, 40000); 477 OSDMap result = WebUtil.PostToService(uri, args, 40000, false);
478
479 if (result == null)
480 return false;
481 bool success = result["success"].AsBoolean();
482 if (!success)
483 return false;
448 } 484 }
449 catch (Exception e) 485 catch (Exception e)
450 { 486 {
451 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString()); 487 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CreateObject failed with exception; {0}",e.ToString());
488 return false;
452 } 489 }
453 490
454 return true; 491 return true;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index 6d5ce28..c21db54 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -32,14 +32,15 @@ using System.IO;
32using System.Reflection; 32using System.Reflection;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35
36using OpenSim.Framework.ServiceAuth;
36using OpenSim.Server.Base; 37using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
38using OpenMetaverse; 39using OpenMetaverse;
39 40
40namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.Connectors
41{ 42{
42 public class UserAccountServicesConnector : IUserAccountService 43 public class UserAccountServicesConnector : BaseServiceConnector, IUserAccountService
43 { 44 {
44 private static readonly ILog m_log = 45 private static readonly ILog m_log =
45 LogManager.GetLogger( 46 LogManager.GetLogger(
@@ -79,6 +80,8 @@ namespace OpenSim.Services.Connectors
79 throw new Exception("User account connector init error"); 80 throw new Exception("User account connector init error");
80 } 81 }
81 m_ServerURI = serviceURI; 82 m_ServerURI = serviceURI;
83
84 base.Initialise(source, "UserAccountService");
82 } 85 }
83 86
84 public virtual UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) 87 public virtual UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
@@ -144,7 +147,8 @@ namespace OpenSim.Services.Connectors
144 { 147 {
145 reply = SynchronousRestFormsRequester.MakeRequest("POST", 148 reply = SynchronousRestFormsRequester.MakeRequest("POST",
146 uri, 149 uri,
147 reqString); 150 reqString,
151 m_Auth);
148 if (reply == null || (reply != null && reply == string.Empty)) 152 if (reply == null || (reply != null && reply == string.Empty))
149 { 153 {
150 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply"); 154 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccounts received null or empty reply");
@@ -162,7 +166,7 @@ namespace OpenSim.Services.Connectors
162 166
163 if (replyData != null) 167 if (replyData != null)
164 { 168 {
165 if (replyData.ContainsKey("result") && replyData.ContainsKey("result").ToString() == "null") 169 if (replyData.ContainsKey("result") && replyData["result"].ToString() == "null")
166 { 170 {
167 return accounts; 171 return accounts;
168 } 172 }
@@ -187,6 +191,10 @@ namespace OpenSim.Services.Connectors
187 return accounts; 191 return accounts;
188 } 192 }
189 193
194 public void InvalidateCache(UUID userID)
195 {
196 }
197
190 public virtual bool StoreUserAccount(UserAccount data) 198 public virtual bool StoreUserAccount(UserAccount data)
191 { 199 {
192 Dictionary<string, object> sendData = new Dictionary<string, object>(); 200 Dictionary<string, object> sendData = new Dictionary<string, object>();
@@ -207,9 +215,39 @@ namespace OpenSim.Services.Connectors
207 sendData[kvp.Key] = kvp.Value.ToString(); 215 sendData[kvp.Key] = kvp.Value.ToString();
208 } 216 }
209 217
210 return SendAndGetBoolReply(sendData); 218 if (SendAndGetReply(sendData) != null)
219 return true;
220 else
221 return false;
211 } 222 }
212 223
224 /// <summary>
225 /// Create user remotely. Note this this is not part of the IUserAccountsService
226 /// </summary>
227 /// <param name="first"></param>
228 /// <param name="last"></param>
229 /// <param name="password"></param>
230 /// <param name="email"></param>
231 /// <param name="scopeID"></param>
232 /// <returns></returns>
233 public virtual UserAccount CreateUser(string first, string last, string password, string email, UUID scopeID)
234 {
235 Dictionary<string, object> sendData = new Dictionary<string, object>();
236 //sendData["SCOPEID"] = scopeID.ToString();
237 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
238 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
239 sendData["METHOD"] = "createuser";
240
241 sendData["FirstName"] = first;
242 sendData["LastName"] = last;
243 sendData["Password"] = password;
244 if (!string.IsNullOrEmpty(email))
245 sendData["Email"] = first;
246 sendData["ScopeID"] = scopeID.ToString();
247
248 return SendAndGetReply(sendData);
249 }
250
213 private UserAccount SendAndGetReply(Dictionary<string, object> sendData) 251 private UserAccount SendAndGetReply(Dictionary<string, object> sendData)
214 { 252 {
215 string reply = string.Empty; 253 string reply = string.Empty;
@@ -220,7 +258,8 @@ namespace OpenSim.Services.Connectors
220 { 258 {
221 reply = SynchronousRestFormsRequester.MakeRequest("POST", 259 reply = SynchronousRestFormsRequester.MakeRequest("POST",
222 uri, 260 uri,
223 reqString); 261 reqString,
262 m_Auth);
224 if (reply == null || (reply != null && reply == string.Empty)) 263 if (reply == null || (reply != null && reply == string.Empty))
225 { 264 {
226 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); 265 m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply");
@@ -251,14 +290,16 @@ namespace OpenSim.Services.Connectors
251 { 290 {
252 string reqString = ServerUtils.BuildQueryString(sendData); 291 string reqString = ServerUtils.BuildQueryString(sendData);
253 string uri = m_ServerURI + "/accounts"; 292 string uri = m_ServerURI + "/accounts";
254 // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); 293 //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString);
255 try 294 try
256 { 295 {
257 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 296 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
258 uri, 297 uri,
259 reqString); 298 reqString,
299 m_Auth);
260 if (reply != string.Empty) 300 if (reply != string.Empty)
261 { 301 {
302 //m_log.DebugFormat("[ACCOUNTS CONNECTOR]: reply = {0}", reply);
262 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 303 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
263 304
264 if (replyData.ContainsKey("result")) 305 if (replyData.ContainsKey("result"))
diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/EstateService/EstateDataService.cs
index cdcdecf..f6a8654 100644
--- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs
+++ b/OpenSim/Services/EstateService/EstateDataService.cs
@@ -29,17 +29,14 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using log4net; 31using log4net;
32using Mono.Addins;
33using Nini.Config; 32using Nini.Config;
34using System.Reflection; 33using System.Reflection;
35using OpenSim.Services.Base; 34using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
37using OpenSim.Data; 36using OpenSim.Data;
38using OpenSim.Framework; 37using OpenSim.Framework;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41 38
42namespace OpenSim.Services.Connectors 39namespace OpenSim.Services.EstateService
43{ 40{
44 public class EstateDataService : ServiceBase, IEstateDataService 41 public class EstateDataService : ServiceBase, IEstateDataService
45 { 42 {
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs
index 504fcaf..d9684c4 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
+++ b/OpenSim/Services/SimulationService/SimulationDataService.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using log4net; 31using log4net;
32using Mono.Addins;
33using Nini.Config; 32using Nini.Config;
34using System.Reflection; 33using System.Reflection;
35using OpenSim.Services.Base; 34using OpenSim.Services.Base;
@@ -39,7 +38,7 @@ using OpenSim.Framework;
39using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
41 40
42namespace OpenSim.Services.Connectors 41namespace OpenSim.Services.SimulationService
43{ 42{
44 public class SimulationDataService : ServiceBase, ISimulationDataService 43 public class SimulationDataService : ServiceBase, ISimulationDataService
45 { 44 {
@@ -100,6 +99,11 @@ namespace OpenSim.Services.Connectors
100 return m_database.LoadObjects(regionUUID); 99 return m_database.LoadObjects(regionUUID);
101 } 100 }
102 101
102 public void StoreTerrain(TerrainData terrain, UUID regionID)
103 {
104 m_database.StoreTerrain(terrain, regionID);
105 }
106
103 public void StoreTerrain(double[,] terrain, UUID regionID) 107 public void StoreTerrain(double[,] terrain, UUID regionID)
104 { 108 {
105 m_database.StoreTerrain(terrain, regionID); 109 m_database.StoreTerrain(terrain, regionID);
@@ -110,6 +114,11 @@ namespace OpenSim.Services.Connectors
110 return m_database.LoadTerrain(regionID); 114 return m_database.LoadTerrain(regionID);
111 } 115 }
112 116
117 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
118 {
119 return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
120 }
121
113 public void StoreLandObject(ILandObject Parcel) 122 public void StoreLandObject(ILandObject Parcel)
114 { 123 {
115 m_database.StoreLandObject(Parcel); 124 m_database.StoreLandObject(Parcel);