aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie Thielker2014-06-21 00:39:55 +0200
committerMelanie Thielker2014-06-21 00:39:55 +0200
commit159fcbf150b7da0e229b29aa7b94793484543d12 (patch)
treeb8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Services
parentMerge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.zip
opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz
opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2
opensim-SC_OLD-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AssetService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/AssetService/XAssetService.cs7
-rw-r--r--OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/Base/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs51
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs68
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs140
-rw-r--r--OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs1
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs124
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs19
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs507
-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.cs114
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs131
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs30
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs30
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs212
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs8
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs102
-rw-r--r--OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/Friends/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/GridService/GridService.cs99
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs2
-rw-r--r--OpenSim/Services/GridService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs43
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs2
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs69
-rw-r--r--OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs216
-rw-r--r--OpenSim/Services/HypergridService/UserAgentServiceBase.cs84
-rw-r--r--OpenSim/Services/Interfaces/IBansService.cs48
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs47
-rw-r--r--OpenSim/Services/Interfaces/IHypergridServices.cs8
-rw-r--r--OpenSim/Services/Interfaces/IOfflineIMService.cs7
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs12
-rw-r--r--OpenSim/Services/Interfaces/IUserProfilesService.cs75
-rw-r--r--OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs44
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs14
-rw-r--r--OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/MapImageService/MapImageService.cs2
-rw-r--r--OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs63
-rw-r--r--OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesService.cs262
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs86
59 files changed, 2097 insertions, 896 deletions
diff --git a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs b/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
index 50ee033..72c2ac4 100644
--- a/OpenSim/Services/AssetService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AssetService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index 8a2ca7c..6047616 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -205,15 +205,16 @@ namespace OpenSim.Services.AssetService
205 if (!UUID.TryParse(id, out assetID)) 205 if (!UUID.TryParse(id, out assetID))
206 return false; 206 return false;
207 207
208 // Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens 208 if (HasChainedAssetService)
209 // very rarely. 209 m_ChainedAssetService.Delete(id);
210 210
211 return m_Database.Delete(id); 211 return m_Database.Delete(id);
212 } 212 }
213 213
214 private void MigrateFromChainedService(AssetBase asset) 214 private void MigrateFromChainedService(AssetBase asset)
215 { 215 {
216 Util.FireAndForget(o => { Store(asset); m_ChainedAssetService.Delete(asset.ID); }); 216 Store(asset);
217 m_ChainedAssetService.Delete(asset.ID);
217 } 218 }
218 } 219 }
219} \ No newline at end of file 220} \ No newline at end of file
diff --git a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
index 435852da..8ffeeca 100644
--- a/OpenSim/Services/AuthenticationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthenticationService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs b/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
index 8db1671..e51d2ca 100644
--- a/OpenSim/Services/AuthorizationService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AuthorizationService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs b/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
index 138d4cd..3800e62 100644
--- a/OpenSim/Services/AvatarService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/AvatarService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/Base/Properties/AssemblyInfo.cs b/OpenSim/Services/Base/Properties/AssemblyInfo.cs
index 84a40f0..959670c 100644
--- a/OpenSim/Services/Base/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Base/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 8b702e0..bf0cc35 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -66,6 +66,12 @@ namespace OpenSim.Services.Connectors
66 66
67 private Thread[] m_fetchThreads; 67 private Thread[] m_fetchThreads;
68 68
69 public int MaxAssetRequestConcurrency
70 {
71 get { return m_maxAssetRequestConcurrency; }
72 set { m_maxAssetRequestConcurrency = value; }
73 }
74
69 public AssetServicesConnector() 75 public AssetServicesConnector()
70 { 76 {
71 } 77 }
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index f982cc1..af91cdb 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -525,6 +525,57 @@ namespace OpenSim.Services.Connectors
525 return rinfos; 525 return rinfos;
526 } 526 }
527 527
528 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
529 {
530 Dictionary<string, object> sendData = new Dictionary<string, object>();
531
532 sendData["SCOPEID"] = scopeID.ToString();
533
534 sendData["METHOD"] = "get_default_hypergrid_regions";
535
536 List<GridRegion> rinfos = new List<GridRegion>();
537 string reply = string.Empty;
538 string uri = m_ServerURI + "/grid";
539 try
540 {
541 reply = SynchronousRestFormsRequester.MakeRequest("POST",
542 uri,
543 ServerUtils.BuildQueryString(sendData));
544
545 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
546 }
547 catch (Exception e)
548 {
549 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
550 return rinfos;
551 }
552
553 if (reply != string.Empty)
554 {
555 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
556
557 if (replyData != null)
558 {
559 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
560 foreach (object r in rinfosList)
561 {
562 if (r is Dictionary<string, object>)
563 {
564 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
565 rinfos.Add(rinfo);
566 }
567 }
568 }
569 else
570 m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response",
571 scopeID);
572 }
573 else
574 m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply");
575
576 return rinfos;
577 }
578
528 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 579 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
529 { 580 {
530 Dictionary<string, object> sendData = new Dictionary<string, object>(); 581 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
index 94bda82..1a62d2f 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
@@ -214,7 +214,7 @@ namespace OpenSim.Services.Connectors
214 214
215 } 215 }
216 else 216 else
217 m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply"); 217 m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply");
218 } 218 }
219 catch (Exception e) 219 catch (Exception e)
220 { 220 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index d840527..803cd1b 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 }
@@ -179,7 +182,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
179 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); 182 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
180 imageData = OpenJPEG.EncodeFromImage(bitmap, true); 183 imageData = OpenJPEG.EncodeFromImage(bitmap, true);
181 } 184 }
182 185
183 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); 186 AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString());
184 187
185 // !!! for now 188 // !!! for now
@@ -257,7 +260,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
257 region.RegionName = (string)hash["region_name"]; 260 region.RegionName = (string)hash["region_name"];
258 //m_log.Debug(">> HERE, region_name: " + region.RegionName); 261 //m_log.Debug(">> HERE, region_name: " + region.RegionName);
259 } 262 }
260 if (hash["hostname"] != null) { 263 if (hash["hostname"] != null)
264 {
261 region.ExternalHostName = (string)hash["hostname"]; 265 region.ExternalHostName = (string)hash["hostname"];
262 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); 266 //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName);
263 } 267 }
@@ -275,10 +279,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
275 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); 279 region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p);
276 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); 280 //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint);
277 } 281 }
278 282
279 if (hash["server_uri"] != null) 283 if (hash["server_uri"] != null)
280 { 284 {
281 region.ServerURI = (string) hash["server_uri"]; 285 region.ServerURI = (string)hash["server_uri"];
282 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); 286 //m_log.Debug(">> HERE, server_uri: " + region.ServerURI);
283 } 287 }
284 288
@@ -295,55 +299,5 @@ namespace OpenSim.Services.Connectors.Hypergrid
295 299
296 return null; 300 return null;
297 } 301 }
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 } 302 }
349} 303}
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/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index d7e38f1..32ea4ee 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -44,13 +44,14 @@ 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_ServerURL;
54 private GridRegion m_Gatekeeper;
54 55
55 public UserAgentServiceConnector(string url) : this(url, true) 56 public UserAgentServiceConnector(string url) : this(url, true)
56 { 57 {
@@ -102,9 +103,15 @@ namespace OpenSim.Services.Connectors.Hypergrid
102 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); 103 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
103 } 104 }
104 105
106 protected override string AgentPath()
107 {
108 return "homeagent/";
109 }
105 110
106 // The Login service calls this interface with a non-null [client] ipaddress 111 // The Login service calls this interface with fromLogin=true
107 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) 112 // Sims call it with fromLogin=false
113 // Either way, this is verified by the handler
114 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason)
108 { 115 {
109 reason = String.Empty; 116 reason = String.Empty;
110 117
@@ -115,119 +122,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
115 return false; 122 return false;
116 } 123 }
117 124
118 string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/"; 125 GridRegion home = new GridRegion();
119 126 home.ServerURI = m_ServerURL;
120 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); 127 home.RegionID = destination.RegionID;
121 128 home.RegionLocX = destination.RegionLocX;
122 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); 129 home.RegionLocY = destination.RegionLocY;
123 AgentCreateRequest.Method = "POST";
124 AgentCreateRequest.ContentType = "application/json";
125 AgentCreateRequest.Timeout = 10000;
126 //AgentCreateRequest.KeepAlive = false;
127 //AgentCreateRequest.Headers.Add("Authorization", authKey);
128
129 // Fill it in
130 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
131
132 string strBuffer = "";
133 byte[] buffer = new byte[1];
134 try
135 {
136 strBuffer = OSDParser.SerializeJsonString(args);
137 Encoding str = Util.UTF8;
138 buffer = str.GetBytes(strBuffer);
139
140 }
141 catch (Exception e)
142 {
143 m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
144 // ignore. buffer will be empty, caller should check.
145 }
146
147 Stream os = null;
148 try
149 { // send the Post
150 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
151 os = AgentCreateRequest.GetRequestStream();
152 os.Write(buffer, 0, strBuffer.Length); //Send it
153 m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
154 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
155 }
156 //catch (WebException ex)
157 catch
158 {
159 //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
160 reason = "cannot contact remote region";
161 return false;
162 }
163 finally
164 {
165 if (os != null)
166 os.Close();
167 }
168
169 // Let's wait for the response
170 //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
171 130
172 try 131 m_Gatekeeper = gatekeeper;
173 {
174 using (WebResponse webResponse = AgentCreateRequest.GetResponse())
175 {
176 if (webResponse == null)
177 {
178 m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
179 }
180 else
181 {
182 using (Stream s = webResponse.GetResponseStream())
183 {
184 using (StreamReader sr = new StreamReader(s))
185 {
186 string response = sr.ReadToEnd().Trim();
187 m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
188
189 if (!String.IsNullOrEmpty(response))
190 {
191 try
192 {
193 // we assume we got an OSDMap back
194 OSDMap r = Util.GetOSDMap(response);
195 bool success = r["success"].AsBoolean();
196 reason = r["reason"].AsString();
197 return success;
198 }
199 catch (NullReferenceException e)
200 {
201 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
202
203 // check for old style response
204 if (response.ToLower().StartsWith("true"))
205 return true;
206
207 return false;
208 }
209 }
210 }
211 }
212 }
213 }
214 }
215 catch (WebException ex)
216 {
217 m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
218 reason = "Destination did not reply";
219 return false;
220 }
221 132
222 return true; 133 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
223 134
135 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
136 return CreateAgent(home, aCircuit, flags, out reason);
224 } 137 }
225 138
226 139
227 // The simulators call this interface 140 // The simulators call this interface
228 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) 141 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
229 { 142 {
230 return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); 143 return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason);
144 }
145
146 protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
147 {
148 base.PackData(args, aCircuit, destination, flags);
149 args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI);
150 args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName);
151 args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString());
152 args["destination_serveruri"] = OSD.FromString(destination.ServerURI);
231 } 153 }
232 154
233 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) 155 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
@@ -633,7 +555,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
633 } 555 }
634 catch 556 catch
635 { 557 {
636 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL); 558 m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs for user {1}", m_ServerURL, userID);
637// reason = "Exception: " + e.Message; 559// reason = "Exception: " + e.Message;
638 return serverURLs; 560 return serverURLs;
639 } 561 }
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..36d4ae2 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -84,6 +84,30 @@ namespace OpenSim.Services.Connectors
84 m_ServerURI = serviceURI; 84 m_ServerURI = serviceURI;
85 } 85 }
86 86
87 private bool CheckReturn(Dictionary<string, object> ret)
88 {
89 if (ret == null)
90 return false;
91
92 if (ret.Count == 0)
93 return false;
94
95 if (ret.ContainsKey("RESULT"))
96 {
97 if (ret["RESULT"] is string)
98 {
99 bool result;
100
101 if (bool.TryParse((string)ret["RESULT"], out result))
102 return result;
103
104 return false;
105 }
106 }
107
108 return true;
109 }
110
87 public bool CreateUserInventory(UUID principalID) 111 public bool CreateUserInventory(UUID principalID)
88 { 112 {
89 Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY", 113 Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY",
@@ -91,12 +115,7 @@ namespace OpenSim.Services.Connectors
91 { "PRINCIPAL", principalID.ToString() } 115 { "PRINCIPAL", principalID.ToString() }
92 }); 116 });
93 117
94 if (ret == null) 118 return CheckReturn(ret);
95 return false;
96 if (ret.Count == 0)
97 return false;
98
99 return bool.Parse(ret["RESULT"].ToString());
100 } 119 }
101 120
102 public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) 121 public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
@@ -106,9 +125,7 @@ namespace OpenSim.Services.Connectors
106 { "PRINCIPAL", principalID.ToString() } 125 { "PRINCIPAL", principalID.ToString() }
107 }); 126 });
108 127
109 if (ret == null) 128 if (!CheckReturn(ret))
110 return null;
111 if (ret.Count == 0)
112 return null; 129 return null;
113 130
114 Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; 131 Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"];
@@ -135,9 +152,7 @@ namespace OpenSim.Services.Connectors
135 { "PRINCIPAL", principalID.ToString() } 152 { "PRINCIPAL", principalID.ToString() }
136 }); 153 });
137 154
138 if (ret == null) 155 if (!CheckReturn(ret))
139 return null;
140 if (ret.Count == 0)
141 return null; 156 return null;
142 157
143 return BuildFolder((Dictionary<string, object>)ret["folder"]); 158 return BuildFolder((Dictionary<string, object>)ret["folder"]);
@@ -151,9 +166,7 @@ namespace OpenSim.Services.Connectors
151 { "TYPE", ((int)type).ToString() } 166 { "TYPE", ((int)type).ToString() }
152 }); 167 });
153 168
154 if (ret == null) 169 if (!CheckReturn(ret))
155 return null;
156 if (ret.Count == 0)
157 return null; 170 return null;
158 171
159 return BuildFolder((Dictionary<string, object>)ret["folder"]); 172 return BuildFolder((Dictionary<string, object>)ret["folder"]);
@@ -174,9 +187,7 @@ namespace OpenSim.Services.Connectors
174 { "FOLDER", folderID.ToString() } 187 { "FOLDER", folderID.ToString() }
175 }); 188 });
176 189
177 if (ret == null) 190 if (!CheckReturn(ret))
178 return null;
179 if (ret.Count == 0)
180 return null; 191 return null;
181 192
182 Dictionary<string,object> folders = 193 Dictionary<string,object> folders =
@@ -205,9 +216,7 @@ namespace OpenSim.Services.Connectors
205 { "FOLDER", folderID.ToString() } 216 { "FOLDER", folderID.ToString() }
206 }); 217 });
207 218
208 if (ret == null) 219 if (!CheckReturn(ret))
209 return null;
210 if (ret.Count == 0)
211 return null; 220 return null;
212 221
213 Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; 222 Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"];
@@ -230,10 +239,7 @@ namespace OpenSim.Services.Connectors
230 { "ID", folder.ID.ToString() } 239 { "ID", folder.ID.ToString() }
231 }); 240 });
232 241
233 if (ret == null) 242 return CheckReturn(ret);
234 return false;
235
236 return bool.Parse(ret["RESULT"].ToString());
237 } 243 }
238 244
239 public bool UpdateFolder(InventoryFolderBase folder) 245 public bool UpdateFolder(InventoryFolderBase folder)
@@ -248,10 +254,7 @@ namespace OpenSim.Services.Connectors
248 { "ID", folder.ID.ToString() } 254 { "ID", folder.ID.ToString() }
249 }); 255 });
250 256
251 if (ret == null) 257 return CheckReturn(ret);
252 return false;
253
254 return bool.Parse(ret["RESULT"].ToString());
255 } 258 }
256 259
257 public bool MoveFolder(InventoryFolderBase folder) 260 public bool MoveFolder(InventoryFolderBase folder)
@@ -263,10 +266,7 @@ namespace OpenSim.Services.Connectors
263 { "PRINCIPAL", folder.Owner.ToString() } 266 { "PRINCIPAL", folder.Owner.ToString() }
264 }); 267 });
265 268
266 if (ret == null) 269 return CheckReturn(ret);
267 return false;
268
269 return bool.Parse(ret["RESULT"].ToString());
270 } 270 }
271 271
272 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) 272 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
@@ -282,10 +282,7 @@ namespace OpenSim.Services.Connectors
282 { "FOLDERS", slist } 282 { "FOLDERS", slist }
283 }); 283 });
284 284
285 if (ret == null) 285 return CheckReturn(ret);
286 return false;
287
288 return bool.Parse(ret["RESULT"].ToString());
289 } 286 }
290 287
291 public bool PurgeFolder(InventoryFolderBase folder) 288 public bool PurgeFolder(InventoryFolderBase folder)
@@ -295,10 +292,7 @@ namespace OpenSim.Services.Connectors
295 { "ID", folder.ID.ToString() } 292 { "ID", folder.ID.ToString() }
296 }); 293 });
297 294
298 if (ret == null) 295 return CheckReturn(ret);
299 return false;
300
301 return bool.Parse(ret["RESULT"].ToString());
302 } 296 }
303 297
304 public bool AddItem(InventoryItemBase item) 298 public bool AddItem(InventoryItemBase item)
@@ -330,10 +324,7 @@ namespace OpenSim.Services.Connectors
330 { "CreationDate", item.CreationDate.ToString() } 324 { "CreationDate", item.CreationDate.ToString() }
331 }); 325 });
332 326
333 if (ret == null) 327 return CheckReturn(ret);
334 return false;
335
336 return bool.Parse(ret["RESULT"].ToString());
337 } 328 }
338 329
339 public bool UpdateItem(InventoryItemBase item) 330 public bool UpdateItem(InventoryItemBase item)
@@ -365,10 +356,7 @@ namespace OpenSim.Services.Connectors
365 { "CreationDate", item.CreationDate.ToString() } 356 { "CreationDate", item.CreationDate.ToString() }
366 }); 357 });
367 358
368 if (ret == null) 359 return CheckReturn(ret);
369 return false;
370
371 return bool.Parse(ret["RESULT"].ToString());
372 } 360 }
373 361
374 public bool MoveItems(UUID principalID, List<InventoryItemBase> items) 362 public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
@@ -389,10 +377,7 @@ namespace OpenSim.Services.Connectors
389 { "DESTLIST", destlist } 377 { "DESTLIST", destlist }
390 }); 378 });
391 379
392 if (ret == null) 380 return CheckReturn(ret);
393 return false;
394
395 return bool.Parse(ret["RESULT"].ToString());
396 } 381 }
397 382
398 public bool DeleteItems(UUID principalID, List<UUID> itemIDs) 383 public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
@@ -408,10 +393,7 @@ namespace OpenSim.Services.Connectors
408 { "ITEMS", slist } 393 { "ITEMS", slist }
409 }); 394 });
410 395
411 if (ret == null) 396 return CheckReturn(ret);
412 return false;
413
414 return bool.Parse(ret["RESULT"].ToString());
415 } 397 }
416 398
417 public InventoryItemBase GetItem(InventoryItemBase item) 399 public InventoryItemBase GetItem(InventoryItemBase item)
@@ -423,9 +405,7 @@ namespace OpenSim.Services.Connectors
423 { "ID", item.ID.ToString() } 405 { "ID", item.ID.ToString() }
424 }); 406 });
425 407
426 if (ret == null) 408 if (!CheckReturn(ret))
427 return null;
428 if (ret.Count == 0)
429 return null; 409 return null;
430 410
431 return BuildItem((Dictionary<string, object>)ret["item"]); 411 return BuildItem((Dictionary<string, object>)ret["item"]);
@@ -447,9 +427,7 @@ namespace OpenSim.Services.Connectors
447 { "ID", folder.ID.ToString() } 427 { "ID", folder.ID.ToString() }
448 }); 428 });
449 429
450 if (ret == null) 430 if (!CheckReturn(ret))
451 return null;
452 if (ret.Count == 0)
453 return null; 431 return null;
454 432
455 return BuildFolder((Dictionary<string, object>)ret["folder"]); 433 return BuildFolder((Dictionary<string, object>)ret["folder"]);
@@ -469,7 +447,7 @@ namespace OpenSim.Services.Connectors
469 { "PRINCIPAL", principalID.ToString() } 447 { "PRINCIPAL", principalID.ToString() }
470 }); 448 });
471 449
472 if (ret == null) 450 if (!CheckReturn(ret))
473 return null; 451 return null;
474 452
475 List<InventoryItemBase> items = new List<InventoryItemBase>(); 453 List<InventoryItemBase> items = new List<InventoryItemBase>();
@@ -488,10 +466,22 @@ namespace OpenSim.Services.Connectors
488 { "ASSET", assetID.ToString() } 466 { "ASSET", assetID.ToString() }
489 }); 467 });
490 468
469 // 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) 470 if (ret == null)
492 return 0; 471 return 0;
493 472
494 return int.Parse(ret["RESULT"].ToString()); 473 if (ret.ContainsKey("RESULT"))
474 {
475 if (ret["RESULT"] is string)
476 {
477 int intResult;
478
479 if (int.TryParse ((string)ret["RESULT"], out intResult))
480 return intResult;
481 }
482 }
483
484 return 0;
495 } 485 }
496 486
497 public InventoryCollection GetUserInventory(UUID principalID) 487 public InventoryCollection GetUserInventory(UUID principalID)
@@ -508,9 +498,7 @@ namespace OpenSim.Services.Connectors
508 { "PRINCIPAL", principalID.ToString() } 498 { "PRINCIPAL", principalID.ToString() }
509 }); 499 });
510 500
511 if (ret == null) 501 if (!CheckReturn(ret))
512 return null;
513 if (ret.Count == 0)
514 return null; 502 return null;
515 503
516 Dictionary<string, object> folders = 504 Dictionary<string, object> folders =
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index 267dd71..725204d 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -174,29 +174,32 @@ namespace OpenSim.Services.Connectors
174 } 174 }
175 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) 175 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
176 { 176 {
177 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString()); 177 reason = string.Format("Map post to {0} failed: {1}", uri, replyData["Message"].ToString());
178 reason = replyData["Message"].ToString(); 178 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
179
179 return false; 180 return false;
180 } 181 }
181 else if (!replyData.ContainsKey("Result")) 182 else if (!replyData.ContainsKey("Result"))
182 { 183 {
183 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field"); 184 reason = string.Format("Reply data from {0} does not contain result field", uri);
185 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
184 } 186 }
185 else 187 else
186 { 188 {
187 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); 189 reason = string.Format("Unexpected result {0} from {1}" + replyData["Result"].ToString(), uri);
188 reason = "Unexpected result " + replyData["Result"].ToString(); 190 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
189 } 191 }
190
191 } 192 }
192 else 193 else
193 { 194 {
194 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply"); 195 reason = string.Format("Map post received null reply from {0}", uri);
196 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
195 } 197 }
196 } 198 }
197 catch (Exception e) 199 catch (Exception e)
198 { 200 {
199 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message); 201 reason = string.Format("Exception when posting to map server at {0}: {1}", uri, e.Message);
202 m_log.WarnFormat("[MAP IMAGE CONNECTOR]: {0}", reason);
200 } 203 }
201 finally 204 finally
202 { 205 {
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index b36fa23..245703c 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -98,7 +98,7 @@ namespace OpenSim.Services.Connectors
98 catch (Exception e) 98 catch (Exception e)
99 { 99 {
100 m_log.WarnFormat( 100 m_log.WarnFormat(
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}{4}",
102 uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 102 uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
103 103
104 return false; 104 return false;
@@ -117,7 +117,7 @@ namespace OpenSim.Services.Connectors
117 catch (Exception e) 117 catch (Exception e)
118 { 118 {
119 m_log.WarnFormat( 119 m_log.WarnFormat(
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}{3}",
121 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 121 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
122 122
123 return false; 123 return false;
@@ -137,7 +137,7 @@ namespace OpenSim.Services.Connectors
137 catch (Exception e) 137 catch (Exception e)
138 { 138 {
139 m_log.WarnFormat( 139 m_log.WarnFormat(
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}{3}",
141 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); 141 thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
142 142
143 return false; 143 return false;
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Connectors
175 if (webResponse == null) 175 if (webResponse == null)
176 { 176 {
177 m_log.DebugFormat( 177 m_log.DebugFormat(
178 "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}", 178 "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
179 thisRegion.RegionName, region.RegionName); 179 thisRegion.RegionName, region.RegionName);
180 } 180 }
181 181
@@ -193,7 +193,7 @@ namespace OpenSim.Services.Connectors
193 catch (Exception e) 193 catch (Exception e)
194 { 194 {
195 m_log.WarnFormat( 195 m_log.WarnFormat(
196 "[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}{3}",
197 region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace); 197 region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace);
198 198
199 return false; 199 return false;
diff --git a/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs b/OpenSim/Services/Connectors/Properties/AssemblyInfo.cs
index 8b18afb..bc89f5d 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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 74b980c..6f8d9ed 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,7 +223,7 @@ 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 }
261 ); 229 );
@@ -278,7 +246,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
278 } 246 }
279 247
280 bool storedInCache = false; 248 bool storedInCache = false;
281 string errorMessage = null;
282 249
283 // AssetID handling 250 // AssetID handling
284 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) 251 if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID)
@@ -307,83 +274,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
307 return asset.ID; 274 return asset.ID;
308 } 275 }
309 276
310 // Distinguish public and private assets 277 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 using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
344 {
345 using (Stream responseStream = response.GetResponseStream())
346 {
347 string responseStr = null;
348
349 try
350 {
351 responseStr = responseStream.GetStreamString();
352 OSD responseOSD = OSDParser.Deserialize(responseStr);
353 if (responseOSD.Type == OSDType.Map)
354 {
355 OSDMap responseMap = (OSDMap)responseOSD;
356 if (responseMap["Success"].AsBoolean())
357 return asset.ID;
358 else
359 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
360 }
361 else
362 {
363 errorMessage = "Response format was invalid:\n" + responseStr;
364 }
365 }
366 catch (Exception ex)
367 {
368 if (!String.IsNullOrEmpty(responseStr))
369 errorMessage = "Failed to parse the response:\n" + responseStr;
370 else
371 errorMessage = "Failed to retrieve the response: " + ex.Message;
372 }
373 }
374 }
375 }
376 catch (WebException ex)
377 {
378 errorMessage = ex.Message;
379 }
380
381 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
382 asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
383
384 return null;
385 } 278 }
386 279
387 /// <summary> 280 /// <summary>
388 /// Update an asset's content 281 /// Update an asset's content
389 /// </summary> 282 /// </summary>
@@ -393,11 +286,17 @@ namespace OpenSim.Services.Connectors.SimianGrid
393 /// <returns></returns> 286 /// <returns></returns>
394 public bool UpdateContent(string id, byte[] data) 287 public bool UpdateContent(string id, byte[] data)
395 { 288 {
289 if (String.IsNullOrEmpty(m_serverUrl))
290 {
291 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
292 throw new InvalidOperationException();
293 }
294
396 AssetBase asset = Get(id); 295 AssetBase asset = Get(id);
397 296
398 if (asset == null) 297 if (asset == null)
399 { 298 {
400 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating"); 299 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id);
401 return false; 300 return false;
402 } 301 }
403 302
@@ -420,83 +319,347 @@ namespace OpenSim.Services.Connectors.SimianGrid
420 throw new InvalidOperationException(); 319 throw new InvalidOperationException();
421 } 320 }
422 321
423 //string errorMessage = String.Empty;
424 string url = m_serverUrl + id;
425
426 if (m_cache != null) 322 if (m_cache != null)
427 m_cache.Expire(id); 323 m_cache.Expire(id);
428 324
325 return SimianDeleteOperation(id);
326 }
327
328#endregion IAssetService
329
330#region SimianOperations
331 /// <summary>
332 /// Invokes the xRemoveAsset operation on the simian server to delete an asset
333 /// </summary>
334 /// <param name="id"></param>
335 /// <returns></returns>
336 private bool SimianDeleteOperation(string id)
337 {
429 try 338 try
430 { 339 {
431 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); 340 NameValueCollection requestArgs = new NameValueCollection
432 request.Method = "DELETE"; 341 {
342 { "RequestMethod", "xRemoveAsset" },
343 { "AssetID", id }
344 };
433 345
434 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 346 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
347 if (! response["Success"].AsBoolean())
435 { 348 {
436 if (response.StatusCode != HttpStatusCode.NoContent) 349 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString());
437 { 350 return false;
438 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " +
439 response.StatusCode + " (" + response.StatusDescription + ")");
440 }
441 } 351 }
442 352
443 return true; 353 return true;
354
444 } 355 }
445 catch (Exception ex) 356 catch (Exception ex)
446 { 357 {
447 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message); 358 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message);
448 return false;
449 } 359 }
450 }
451 360
452 #endregion IAssetService 361 return false;
362 }
453 363
454 private AssetBase GetRemote(string id) 364 /// <summary>
365 /// Invokes the xAddAsset operation on the simian server to create or update an asset
366 /// </summary>
367 /// <param name="id"></param>
368 /// <returns></returns>
369 private string SimianStoreOperation(AssetBase asset)
455 { 370 {
456 AssetBase asset = null; 371 try
457 Uri url; 372 {
373 NameValueCollection requestArgs = new NameValueCollection
374 {
375 { "RequestMethod", "xAddAsset" },
376 { "ContentType", asset.Metadata.ContentType },
377 { "EncodedData", Convert.ToBase64String(asset.Data) },
378 { "AssetID", asset.FullID.ToString() },
379 { "CreatorID", asset.Metadata.CreatorID },
380 { "Temporary", asset.Temporary ? "1" : "0" },
381 { "Name", asset.Name }
382 };
383
384 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
385 if (! response["Success"].AsBoolean())
386 {
387 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString());
388 return null;
389 }
458 390
459 // Determine if id is an absolute URL or a grid-relative UUID 391 // asset.ID is always set before calling this function
460 if (!Uri.TryCreate(id, UriKind.Absolute, out url)) 392 return asset.ID;
461 url = new Uri(m_serverUrl + id); 393
394 }
395 catch (Exception ex)
396 {
397 m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message);
398 }
399
400 return null;
401 }
462 402
463 try 403 /// <summary>
404 /// Invokes the xGetAsset operation on the simian server to get data associated with an asset
405 /// </summary>
406 /// <param name="id"></param>
407 /// <returns></returns>
408 private AssetBase SimianGetOperation(string id)
409 {
410 try
464 { 411 {
465 HttpWebRequest request = UntrustedHttpWebRequest.Create(url); 412 NameValueCollection requestArgs = new NameValueCollection
413 {
414 { "RequestMethod", "xGetAsset" },
415 { "ID", id }
416 };
466 417
467 using (WebResponse response = request.GetResponse()) 418 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
419 if (! response["Success"].AsBoolean())
468 { 420 {
469 using (Stream responseStream = response.GetResponseStream()) 421 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString());
470 { 422 return null;
471 string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
472
473 // Create the asset object
474 asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
475
476 UUID assetID;
477 if (UUID.TryParse(id, out assetID))
478 asset.FullID = assetID;
479
480 // Grab the asset data from the response stream
481 using (MemoryStream stream = new MemoryStream())
482 {
483 responseStream.CopyStream(stream, Int32.MaxValue);
484 asset.Data = stream.ToArray();
485 }
486 }
487 } 423 }
424
425 AssetBase asset = new AssetBase();
488 426
489 // Cache store 427 asset.ID = id;
490 if (m_cache != null && asset != null) 428 asset.Name = String.Empty;
491 m_cache.Cache(asset); 429 asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property
430 asset.CreatorID = response["CreatorID"].AsString();
431 asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString());
432 asset.Local = false;
433 asset.Temporary = response["Temporary"];
492 434
493 return asset; 435 return asset;
494 } 436 }
495 catch (Exception ex) 437 catch (Exception ex)
496 { 438 {
497 m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); 439 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message);
498 return null;
499 } 440 }
441
442 return null;
443 }
444
445 /// <summary>
446 /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset
447 /// This operation is generally used to determine if an asset exists in the database
448 /// </summary>
449 /// <param name="id"></param>
450 /// <returns></returns>
451 private AssetMetadata SimianGetMetadataOperation(string id)
452 {
453 try
454 {
455 NameValueCollection requestArgs = new NameValueCollection
456 {
457 { "RequestMethod", "xGetAssetMetadata" },
458 { "ID", id }
459 };
460
461 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
462 if (! response["Success"].AsBoolean())
463 {
464 // this is not really an error, this call is used to test existence
465 // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString());
466 return null;
467 }
468
469 AssetMetadata metadata = new AssetMetadata();
470 metadata.ID = id;
471 metadata.ContentType = response["ContentType"].AsString();
472 metadata.CreatorID = response["CreatorID"].AsString();
473 metadata.Local = false;
474 metadata.Temporary = response["Temporary"];
475
476 string lastModifiedStr = response["Last-Modified"].AsString();
477 if (! String.IsNullOrEmpty(lastModifiedStr))
478 {
479 DateTime lastModified;
480 if (DateTime.TryParse(lastModifiedStr, out lastModified))
481 metadata.CreationDate = lastModified;
482 }
483
484 return metadata;
485 }
486 catch (Exception ex)
487 {
488 m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message);
489 }
490
491 return null;
500 } 492 }
493#endregion
494
495 // private AssetMetadata GetRemoteMetadata(string id)
496 // {
497 // Uri url;
498 // AssetMetadata metadata = null;
499
500 // // Determine if id is an absolute URL or a grid-relative UUID
501 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
502 // url = new Uri(m_serverUrl + id);
503
504 // try
505 // {
506 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
507 // request.Method = "HEAD";
508
509 // using (WebResponse response = request.GetResponse())
510 // {
511 // using (Stream responseStream = response.GetResponseStream())
512 // {
513 // // Create the metadata object
514 // metadata = new AssetMetadata();
515 // metadata.ContentType = response.ContentType;
516 // metadata.ID = id;
517
518 // UUID uuid;
519 // if (UUID.TryParse(id, out uuid))
520 // metadata.FullID = uuid;
521
522 // string lastModifiedStr = response.Headers.Get("Last-Modified");
523 // if (!String.IsNullOrEmpty(lastModifiedStr))
524 // {
525 // DateTime lastModified;
526 // if (DateTime.TryParse(lastModifiedStr, out lastModified))
527 // metadata.CreationDate = lastModified;
528 // }
529 // }
530 // }
531 // }
532 // catch (Exception ex)
533 // {
534 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message);
535 // }
536
537 // return metadata;
538 // }
539
540 // private AssetBase GetRemote(string id)
541 // {
542 // AssetBase asset = null;
543 // Uri url;
544
545 // // Determine if id is an absolute URL or a grid-relative UUID
546 // if (!Uri.TryCreate(id, UriKind.Absolute, out url))
547 // url = new Uri(m_serverUrl + id);
548
549 // try
550 // {
551 // HttpWebRequest request = UntrustedHttpWebRequest.Create(url);
552
553 // using (WebResponse response = request.GetResponse())
554 // {
555 // using (Stream responseStream = response.GetResponseStream())
556 // {
557 // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty;
558
559 // // Create the asset object
560 // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID);
561
562 // UUID assetID;
563 // if (UUID.TryParse(id, out assetID))
564 // asset.FullID = assetID;
565
566 // // Grab the asset data from the response stream
567 // using (MemoryStream stream = new MemoryStream())
568 // {
569 // responseStream.CopyStream(stream, Int32.MaxValue);
570 // asset.Data = stream.ToArray();
571 // }
572 // }
573 // }
574
575 // // Cache store
576 // if (m_cache != null && asset != null)
577 // m_cache.Cache(asset);
578
579 // return asset;
580 // }
581 // catch (Exception ex)
582 // {
583 // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message);
584 // return null;
585 // }
586 // }
587
588 // private string StoreRemote(AssetBase asset)
589 // {
590 // // Distinguish public and private assets
591 // bool isPublic = true;
592 // switch ((AssetType)asset.Type)
593 // {
594 // case AssetType.CallingCard:
595 // case AssetType.Gesture:
596 // case AssetType.LSLBytecode:
597 // case AssetType.LSLText:
598 // isPublic = false;
599 // break;
600 // }
601
602 // string errorMessage = null;
603
604 // // Build the remote storage request
605 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
606 // {
607 // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()),
608 // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID),
609 // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"),
610 // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"),
611 // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data)
612 // };
613
614 // // Make the remote storage request
615 // try
616 // {
617 // // Simian does not require the asset ID to be in the URL because it's in the post data.
618 // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
619 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
620
621 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
622 // {
623 // using (Stream responseStream = response.GetResponseStream())
624 // {
625 // string responseStr = null;
626
627 // try
628 // {
629 // responseStr = responseStream.GetStreamString();
630 // OSD responseOSD = OSDParser.Deserialize(responseStr);
631 // if (responseOSD.Type == OSDType.Map)
632 // {
633 // OSDMap responseMap = (OSDMap)responseOSD;
634 // if (responseMap["Success"].AsBoolean())
635 // return asset.ID;
636 // else
637 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
638 // }
639 // else
640 // {
641 // errorMessage = "Response format was invalid:\n" + responseStr;
642 // }
643 // }
644 // catch (Exception ex)
645 // {
646 // if (!String.IsNullOrEmpty(responseStr))
647 // errorMessage = "Failed to parse the response:\n" + responseStr;
648 // else
649 // errorMessage = "Failed to retrieve the response: " + ex.Message;
650 // }
651 // }
652 // }
653 // }
654 // catch (WebException ex)
655 // {
656 // errorMessage = ex.Message;
657 // }
658
659 // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
660 // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
661
662 // return null;
663 // }
501 } 664 }
502} 665}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 03b19ae..c402907 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -116,7 +116,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
116 { "UserID", principalID.ToString() } 116 { "UserID", principalID.ToString() }
117 }; 117 };
118 118
119 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 119 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
120 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) 120 if (response["Success"].AsBoolean() && response["Identities"] is OSDArray)
121 { 121 {
122 bool md5hashFound = false; 122 bool md5hashFound = false;
@@ -159,7 +159,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
159 { "SessionID", token } 159 { "SessionID", token }
160 }; 160 };
161 161
162 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 162 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
163 if (response["Success"].AsBoolean()) 163 if (response["Success"].AsBoolean())
164 { 164 {
165 return true; 165 return true;
@@ -181,7 +181,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
181 { "UserID", principalID.ToString() } 181 { "UserID", principalID.ToString() }
182 }; 182 };
183 183
184 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 184 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
185 if (response["Success"].AsBoolean()) 185 if (response["Success"].AsBoolean())
186 { 186 {
187 return true; 187 return true;
@@ -204,7 +204,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
204 { "UserID", principalID.ToString() } 204 { "UserID", principalID.ToString() }
205 }; 205 };
206 206
207 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 207 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
208 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 208 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
209 { 209 {
210 OSDMap userMap = (OSDMap)response["User"]; 210 OSDMap userMap = (OSDMap)response["User"];
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
224 { "UserID", principalID.ToString() } 224 { "UserID", principalID.ToString() }
225 }; 225 };
226 226
227 response = WebUtil.PostToService(m_serverUrl, requestArgs); 227 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
228 bool success = response["Success"].AsBoolean(); 228 bool success = response["Success"].AsBoolean();
229 229
230 if (!success) 230 if (!success)
@@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
303 { "UserID", userID.ToString() } 303 { "UserID", userID.ToString() }
304 }; 304 };
305 305
306 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 306 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
307 if (response["Success"].AsBoolean()) 307 if (response["Success"].AsBoolean())
308 return response["SessionID"].AsUUID().ToString(); 308 return response["SessionID"].AsUUID().ToString();
309 else 309 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..9898da9 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", "1.0")]
33[assembly: AddinDependency("OpenSim", "0.5")] 43[assembly: AddinDependency("OpenSim", "0.5")]
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..b999509 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>
@@ -196,67 +198,84 @@ namespace OpenSim.Region.OptionalModules.Simian
196 } 198 }
197 } 199 }
198 200
199 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() 201 NameValueCollection requestArgs = new NameValueCollection
202 {
203 { "RequestMethod", "xAddMapTile" },
204 { "X", scene.RegionInfo.RegionLocX.ToString() },
205 { "Y", scene.RegionInfo.RegionLocY.ToString() },
206 { "ContentType", "image/png" },
207 { "EncodedData", System.Convert.ToBase64String(pngData) }
208 };
209
210 OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs);
211 if (! response["Success"].AsBoolean())
200 { 212 {
201 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), 213 m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString());
202 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), 214 return;
203 new MultipartForm.File("Tile", "tile.png", "image/png", pngData) 215 }
204 };
205 216
206 string errorMessage = null; 217 // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
207 int tickstart = Util.EnvironmentTickCount(); 218 // {
219 // new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
220 // new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
221 // new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
222 // };
208 223
209 // Make the remote storage request 224 // string errorMessage = null;
210 try 225 // int tickstart = Util.EnvironmentTickCount();
211 {
212 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
213 request.Timeout = 20000;
214 request.ReadWriteTimeout = 5000;
215 226
216 using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) 227 // // Make the remote storage request
217 { 228 // try
218 using (Stream responseStream = response.GetResponseStream()) 229 // {
219 { 230 // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
220 string responseStr = responseStream.GetStreamString(); 231 // request.Timeout = 20000;
221 OSD responseOSD = OSDParser.Deserialize(responseStr); 232 // request.ReadWriteTimeout = 5000;
222 if (responseOSD.Type == OSDType.Map)
223 {
224 OSDMap responseMap = (OSDMap)responseOSD;
225 if (responseMap["Success"].AsBoolean())
226 return;
227 233
228 errorMessage = "Upload failed: " + responseMap["Message"].AsString(); 234 // using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
229 } 235 // {
230 else 236 // using (Stream responseStream = response.GetResponseStream())
231 { 237 // {
232 errorMessage = "Response format was invalid:\n" + responseStr; 238 // string responseStr = responseStream.GetStreamString();
233 } 239 // OSD responseOSD = OSDParser.Deserialize(responseStr);
234 } 240 // if (responseOSD.Type == OSDType.Map)
235 } 241 // {
236 } 242 // OSDMap responseMap = (OSDMap)responseOSD;
237 catch (WebException we) 243 // if (responseMap["Success"].AsBoolean())
238 { 244 // return;
239 errorMessage = we.Message; 245
240 if (we.Status == WebExceptionStatus.ProtocolError) 246 // errorMessage = "Upload failed: " + responseMap["Message"].AsString();
241 { 247 // }
242 HttpWebResponse webResponse = (HttpWebResponse)we.Response; 248 // else
243 errorMessage = String.Format("[{0}] {1}", 249 // {
244 webResponse.StatusCode,webResponse.StatusDescription); 250 // errorMessage = "Response format was invalid:\n" + responseStr;
245 } 251 // }
246 } 252 // }
247 catch (Exception ex) 253 // }
248 { 254 // }
249 errorMessage = ex.Message; 255 // catch (WebException we)
250 } 256 // {
251 finally 257 // errorMessage = we.Message;
252 { 258 // if (we.Status == WebExceptionStatus.ProtocolError)
253 // This just dumps a warning for any operation that takes more than 100 ms 259 // {
254 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); 260 // HttpWebResponse webResponse = (HttpWebResponse)we.Response;
255 m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); 261 // errorMessage = String.Format("[{0}] {1}",
256 } 262 // webResponse.StatusCode,webResponse.StatusDescription);
263 // }
264 // }
265 // catch (Exception ex)
266 // {
267 // errorMessage = ex.Message;
268 // }
269 // finally
270 // {
271 // // This just dumps a warning for any operation that takes more than 100 ms
272 // int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
273 // m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff);
274 // }
275
276 // m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
277 // pngData.Length, scene.RegionInfo.RegionName, errorMessage);
257 278
258 m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}",
259 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
260 } 279 }
261 } 280 }
262} \ No newline at end of file 281} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 20eaa3a..3cf3416 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -140,7 +140,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
140 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 140 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
141 }; 141 };
142 142
143 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 143 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
144 if (response["Success"].AsBoolean()) 144 if (response["Success"].AsBoolean())
145 return String.Empty; 145 return String.Empty;
146 else 146 else
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 { "Enabled", "0" } 156 { "Enabled", "0" }
157 }; 157 };
158 158
159 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 159 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
160 bool success = response["Success"].AsBoolean(); 160 bool success = response["Success"].AsBoolean();
161 161
162 if (!success) 162 if (!success)
@@ -203,7 +203,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
203 203
204 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); 204 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString());
205 205
206 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 206 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
207 if (response["Success"].AsBoolean()) 207 if (response["Success"].AsBoolean())
208 { 208 {
209 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); 209 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString());
@@ -231,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
231 231
232 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); 232 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString());
233 233
234 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 234 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
235 if (response["Success"].AsBoolean()) 235 if (response["Success"].AsBoolean())
236 { 236 {
237 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); 237 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString());
@@ -272,7 +272,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
272 272
273 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); 273 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name);
274 274
275 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 275 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
276 if (response["Success"].AsBoolean()) 276 if (response["Success"].AsBoolean())
277 { 277 {
278 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 278 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -310,7 +310,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
310 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); 310 //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString());
311 311
312 312
313 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 313 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
314 if (response["Success"].AsBoolean()) 314 if (response["Success"].AsBoolean())
315 { 315 {
316 OSDArray array = response["Scenes"] as OSDArray; 316 OSDArray array = response["Scenes"] as OSDArray;
@@ -341,6 +341,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
341 return new List<GridRegion>(0); 341 return new List<GridRegion>(0);
342 } 342 }
343 343
344 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
345 {
346 // TODO: Allow specifying the default grid location
347 return GetDefaultRegions(scopeID);
348 }
349
344 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 350 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
345 { 351 {
346 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); 352 GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);
@@ -361,7 +367,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
361 { "Enabled", "1" } 367 { "Enabled", "1" }
362 }; 368 };
363 369
364 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 370 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
365 if (response["Success"].AsBoolean()) 371 if (response["Success"].AsBoolean())
366 { 372 {
367 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); 373 // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name);
@@ -391,7 +397,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
391 397
392 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); 398 m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString());
393 399
394 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 400 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
395 if (response["Success"].AsBoolean()) 401 if (response["Success"].AsBoolean())
396 { 402 {
397 OSDMap extraData = response["ExtraData"] as OSDMap; 403 OSDMap extraData = response["ExtraData"] as OSDMap;
@@ -498,7 +504,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
498 if (onlyEnabled) 504 if (onlyEnabled)
499 requestArgs["Enabled"] = "1"; 505 requestArgs["Enabled"] = "1";
500 506
501 OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); 507 OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs);
502 if (response["Success"].AsBoolean()) 508 if (response["Success"].AsBoolean())
503 { 509 {
504 return ResponseToGridRegion(response); 510 return ResponseToGridRegion(response);
@@ -525,9 +531,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
525 region.RegionName = response["Name"].AsString(); 531 region.RegionName = response["Name"].AsString();
526 532
527 Vector3d minPosition = response["MinPosition"].AsVector3d(); 533 Vector3d minPosition = response["MinPosition"].AsVector3d();
534 Vector3d maxPosition = response["MaxPosition"].AsVector3d();
528 region.RegionLocX = (int)minPosition.X; 535 region.RegionLocX = (int)minPosition.X;
529 region.RegionLocY = (int)minPosition.Y; 536 region.RegionLocY = (int)minPosition.Y;
530 537
538 region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X;
539 region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y;
540
531 if ( ! extraData["HyperGrid"] ) { 541 if ( ! extraData["HyperGrid"] ) {
532 Uri httpAddress = response["Address"].AsUri(); 542 Uri httpAddress = response["Address"].AsUri();
533 region.ExternalHostName = httpAddress.Host; 543 region.ExternalHostName = httpAddress.Host;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 36325ce..97eaabe 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
156 { "OwnerID", userID.ToString() } 156 { "OwnerID", userID.ToString() }
157 }; 157 };
158 158
159 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 159 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
160 bool success = response["Success"].AsBoolean(); 160 bool success = response["Success"].AsBoolean();
161 161
162 if (!success) 162 if (!success)
@@ -182,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
182 { "ChildrenOnly", "0" } 182 { "ChildrenOnly", "0" }
183 }; 183 };
184 184
185 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 185 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
186 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 186 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
187 { 187 {
188 OSDArray items = (OSDArray)response["Items"]; 188 OSDArray items = (OSDArray)response["Items"];
@@ -244,7 +244,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
244 { "ChildrenOnly", "1" } 244 { "ChildrenOnly", "1" }
245 }; 245 };
246 246
247 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 247 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
248 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 248 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
249 { 249 {
250 OSDArray items = (OSDArray)response["Items"]; 250 OSDArray items = (OSDArray)response["Items"];
@@ -274,7 +274,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
274 { "OwnerID", userID.ToString() } 274 { "OwnerID", userID.ToString() }
275 }; 275 };
276 276
277 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 277 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
278 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) 278 if (response["Success"].AsBoolean() && response["Folder"] is OSDMap)
279 { 279 {
280 OSDMap folder = (OSDMap)response["Folder"]; 280 OSDMap folder = (OSDMap)response["Folder"];
@@ -312,7 +312,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
312 { "ChildrenOnly", "1" } 312 { "ChildrenOnly", "1" }
313 }; 313 };
314 314
315 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 315 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
316 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 316 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
317 { 317 {
318 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); 318 List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]);
@@ -349,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
349 { "ChildrenOnly", "1" } 349 { "ChildrenOnly", "1" }
350 }; 350 };
351 351
352 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 352 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 353 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
354 { 354 {
355 OSDArray items = (OSDArray)response["Items"]; 355 OSDArray items = (OSDArray)response["Items"];
@@ -383,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
383 { "ChildrenOnly", "1" } 383 { "ChildrenOnly", "1" }
384 }; 384 };
385 385
386 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 386 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
387 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 387 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
388 { 388 {
389 OSDArray items = (OSDArray)response["Items"]; 389 OSDArray items = (OSDArray)response["Items"];
@@ -423,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
423 { "ChildrenOnly", "1" } 423 { "ChildrenOnly", "1" }
424 }; 424 };
425 425
426 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 426 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
427 if (response["Success"].AsBoolean() && response["Items"] is OSDArray) 427 if (response["Success"].AsBoolean() && response["Items"] is OSDArray)
428 { 428 {
429 OSDArray items = (OSDArray)response["Items"]; 429 OSDArray items = (OSDArray)response["Items"];
@@ -454,7 +454,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
454 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } 454 { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) }
455 }; 455 };
456 456
457 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 457 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
458 bool success = response["Success"].AsBoolean(); 458 bool success = response["Success"].AsBoolean();
459 459
460 if (!success) 460 if (!success)
@@ -518,7 +518,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
518 { "ItemID", itemID.ToString() } 518 { "ItemID", itemID.ToString() }
519 }; 519 };
520 520
521 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 521 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
522 bool success = response["Success"].AsBoolean(); 522 bool success = response["Success"].AsBoolean();
523 523
524 if (!success) 524 if (!success)
@@ -546,7 +546,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
546 { "FolderID", folder.ID.ToString() } 546 { "FolderID", folder.ID.ToString() }
547 }; 547 };
548 548
549 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 549 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
550 bool success = response["Success"].AsBoolean(); 550 bool success = response["Success"].AsBoolean();
551 551
552 if (!success) 552 if (!success)
@@ -623,7 +623,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
623 { "ExtraData", OSDParser.SerializeJsonString(extraData) } 623 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
624 }; 624 };
625 625
626 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 626 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
627 bool success = response["Success"].AsBoolean(); 627 bool success = response["Success"].AsBoolean();
628 628
629 if (!success) 629 if (!success)
@@ -847,7 +847,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
847 { "Items", String.Join(",", itemIDs) } 847 { "Items", String.Join(",", itemIDs) }
848 }; 848 };
849 849
850 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 850 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
851 bool success = response["Success"].AsBoolean(); 851 bool success = response["Success"].AsBoolean();
852 852
853 if (!success) 853 if (!success)
@@ -885,7 +885,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
885 { "UserID", userID.ToString() } 885 { "UserID", userID.ToString() }
886 }; 886 };
887 887
888 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 888 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
889 if (response["Success"].AsBoolean()) 889 if (response["Success"].AsBoolean())
890 { 890 {
891 OSDMap user = response["User"] as OSDMap; 891 OSDMap user = response["User"] as OSDMap;
@@ -916,7 +916,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
916 { "Gestures", OSDParser.SerializeJsonString(gestures) } 916 { "Gestures", OSDParser.SerializeJsonString(gestures) }
917 }; 917 };
918 918
919 OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); 919 OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs);
920 if (!response["Success"].AsBoolean()) 920 if (!response["Success"].AsBoolean())
921 { 921 {
922 m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + 922 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..684a0db 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())
@@ -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 fcb5115..fdc8697 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;
@@ -209,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
209 { "AccessLevel", data.UserLevel.ToString() } 209 { "AccessLevel", data.UserLevel.ToString() }
210 }; 210 };
211 211
212 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 212 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
213 213
214 if (response["Success"].AsBoolean()) 214 if (response["Success"].AsBoolean())
215 { 215 {
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
224 { "UserTitle", data.UserTitle } 224 { "UserTitle", data.UserTitle }
225 }; 225 };
226 226
227 response = WebUtil.PostToService(m_serverUrl, requestArgs); 227 response = SimianGrid.PostToService(m_serverUrl, requestArgs);
228 bool success = response["Success"].AsBoolean(); 228 bool success = response["Success"].AsBoolean();
229 229
230 if (success) 230 if (success)
@@ -257,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
257 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; 257 string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)";
258// 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);
259 259
260 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 260 OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs);
261 if (response["Success"].AsBoolean()) 261 if (response["Success"].AsBoolean())
262 { 262 {
263 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 ef2494a..0e74073 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -79,11 +79,27 @@ namespace OpenSim.Services.Connectors.Simulation
79 return "agent/"; 79 return "agent/";
80 } 80 }
81 81
82 protected virtual void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags)
83 {
84 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
85 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
86 args["destination_name"] = OSD.FromString(destination.RegionName);
87 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
88 args["teleport_flags"] = OSD.FromString(flags.ToString());
89 }
90
82 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 91 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
83 { 92 {
84 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); 93 string tmp = String.Empty;
85 94 return CreateAgent(destination, aCircuit, flags, out tmp, out reason);
95 }
96
97 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
98 {
99 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
86 reason = String.Empty; 100 reason = String.Empty;
101 myipaddress = String.Empty;
102
87 if (destination == null) 103 if (destination == null)
88 { 104 {
89 reason = "Destination not found"; 105 reason = "Destination not found";
@@ -96,12 +112,7 @@ namespace OpenSim.Services.Connectors.Simulation
96 try 112 try
97 { 113 {
98 OSDMap args = aCircuit.PackAgentCircuitData(); 114 OSDMap args = aCircuit.PackAgentCircuitData();
99 115 PackData(args, aCircuit, destination, flags);
100 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
101 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
102 args["destination_name"] = OSD.FromString(destination.RegionName);
103 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
104 args["teleport_flags"] = OSD.FromString(flags.ToString());
105 116
106 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 117 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
107 bool success = result["success"].AsBoolean(); 118 bool success = result["success"].AsBoolean();
@@ -111,6 +122,7 @@ namespace OpenSim.Services.Connectors.Simulation
111 122
112 reason = data["reason"].AsString(); 123 reason = data["reason"].AsString();
113 success = data["success"].AsBoolean(); 124 success = data["success"].AsBoolean();
125 myipaddress = data["your_ip"].AsString();
114 return success; 126 return success;
115 } 127 }
116 128
@@ -125,6 +137,7 @@ namespace OpenSim.Services.Connectors.Simulation
125 137
126 reason = data["reason"].AsString(); 138 reason = data["reason"].AsString();
127 success = data["success"].AsBoolean(); 139 success = data["success"].AsBoolean();
140 myipaddress = data["your_ip"].AsString();
128 m_log.WarnFormat( 141 m_log.WarnFormat(
129 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); 142 "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
130 return success; 143 return success;
@@ -229,7 +242,7 @@ namespace OpenSim.Services.Connectors.Simulation
229 /// </summary> 242 /// </summary>
230 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) 243 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout)
231 { 244 {
232 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start"); 245 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
233 246
234 // Eventually, we want to use a caps url instead of the agentID 247 // Eventually, we want to use a caps url instead of the agentID
235 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; 248 string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/";
@@ -259,41 +272,6 @@ namespace OpenSim.Services.Connectors.Simulation
259 return false; 272 return false;
260 } 273 }
261 274
262 /// <summary>
263 /// Not sure what sequence causes this function to be invoked. The only calling
264 /// path is through the GET method
265 /// </summary>
266 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
267 {
268 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start");
269
270 agent = null;
271
272 // Eventually, we want to use a caps url instead of the agentID
273 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
274
275 try
276 {
277 OSDMap result = WebUtil.GetFromService(uri, 10000);
278 if (result["Success"].AsBoolean())
279 {
280 // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString());
281 OSDMap args = (OSDMap)result["_Result"];
282 if (args != null)
283 {
284 agent = new CompleteAgentData();
285 agent.Unpack(args, null);
286 return true;
287 }
288 }
289 }
290 catch (Exception e)
291 {
292 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString());
293 }
294
295 return false;
296 }
297 275
298 /// <summary> 276 /// <summary>
299 /// </summary> 277 /// </summary>
@@ -392,35 +370,25 @@ namespace OpenSim.Services.Connectors.Simulation
392 return true; 370 return true;
393 } 371 }
394 372
395 private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly) 373 /// <summary>
374 /// </summary>
375 public bool CloseAgent(GridRegion destination, UUID id, string auth_code)
396 { 376 {
397// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); 377 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code;
398 Util.FireAndForget(x => { 378 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri);
399 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
400 379
401 try 380 try
402 { 381 {
403 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); 382 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false);
404 } 383 }
405 catch (Exception e) 384 catch (Exception e)
406 { 385 {
407 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString()); 386 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString());
408 } 387 }
409 });
410 388
411 return true; 389 return true;
412 } 390 }
413 391
414 public bool CloseChildAgent(GridRegion destination, UUID id)
415 {
416 return CloseAgent(destination, id, true);
417 }
418
419 public bool CloseAgent(GridRegion destination, UUID id)
420 {
421 return CloseAgent(destination, id, false);
422 }
423
424 #endregion Agents 392 #endregion Agents
425 393
426 #region Objects 394 #region Objects
diff --git a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs b/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
index b488b36..6bc543a 100644
--- a/OpenSim/Services/FreeswitchService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/FreeswitchService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs b/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
index b11d07d..f9473e2 100644
--- a/OpenSim/Services/Friends/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Friends/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 7f71835..76415ce 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Services.GridService
86 { 86 {
87 MainConsole.Instance.Commands.AddCommand("Regions", true, 87 MainConsole.Instance.Commands.AddCommand("Regions", true,
88 "deregister region id", 88 "deregister region id",
89 "deregister region id <Region UUID>", 89 "deregister region id <region-id>+",
90 "Deregister a region manually.", 90 "Deregister a region manually.",
91 String.Empty, 91 String.Empty,
92 HandleDeregisterRegion); 92 HandleDeregisterRegion);
@@ -265,8 +265,9 @@ namespace OpenSim.Services.GridService
265 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); 265 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
266 } 266 }
267 267
268 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", 268 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}",
269 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); 269 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY,
270 (OpenSim.Framework.RegionFlags)flags);
270 271
271 return String.Empty; 272 return String.Empty;
272 } 273 }
@@ -311,8 +312,9 @@ namespace OpenSim.Services.GridService
311 if (region != null) 312 if (region != null)
312 { 313 {
313 // Not really? Maybe? 314 // Not really? Maybe?
314 List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, 315 List<RegionData> rdatas = m_Database.Get(
315 region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); 316 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1,
317 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
316 318
317 foreach (RegionData rdata in rdatas) 319 foreach (RegionData rdata in rdatas)
318 { 320 {
@@ -345,6 +347,11 @@ namespace OpenSim.Services.GridService
345 return null; 347 return null;
346 } 348 }
347 349
350 // Get a region given its base coordinates.
351 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
352 // be the base coordinate of the region.
353 // The snapping is technically unnecessary but is harmless because regions are always
354 // multiples of the legacy region size (256).
348 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 355 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
349 { 356 {
350 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 357 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -439,6 +446,8 @@ namespace OpenSim.Services.GridService
439 RegionData rdata = new RegionData(); 446 RegionData rdata = new RegionData();
440 rdata.posX = (int)rinfo.RegionLocX; 447 rdata.posX = (int)rinfo.RegionLocX;
441 rdata.posY = (int)rinfo.RegionLocY; 448 rdata.posY = (int)rinfo.RegionLocY;
449 rdata.sizeX = rinfo.RegionSizeX;
450 rdata.sizeY = rinfo.RegionSizeY;
442 rdata.RegionID = rinfo.RegionID; 451 rdata.RegionID = rinfo.RegionID;
443 rdata.RegionName = rinfo.RegionName; 452 rdata.RegionName = rinfo.RegionName;
444 rdata.Data = rinfo.ToKeyValuePairs(); 453 rdata.Data = rinfo.ToKeyValuePairs();
@@ -452,6 +461,8 @@ namespace OpenSim.Services.GridService
452 GridRegion rinfo = new GridRegion(rdata.Data); 461 GridRegion rinfo = new GridRegion(rdata.Data);
453 rinfo.RegionLocX = rdata.posX; 462 rinfo.RegionLocX = rdata.posX;
454 rinfo.RegionLocY = rdata.posY; 463 rinfo.RegionLocY = rdata.posY;
464 rinfo.RegionSizeX = rdata.sizeX;
465 rinfo.RegionSizeY = rdata.sizeY;
455 rinfo.RegionID = rdata.RegionID; 466 rinfo.RegionID = rdata.RegionID;
456 rinfo.RegionName = rdata.RegionName; 467 rinfo.RegionName = rdata.RegionName;
457 rinfo.ScopeID = rdata.ScopeID; 468 rinfo.ScopeID = rdata.ScopeID;
@@ -477,6 +488,33 @@ namespace OpenSim.Services.GridService
477 return ret; 488 return ret;
478 } 489 }
479 490
491 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
492 {
493 List<GridRegion> ret = new List<GridRegion>();
494
495 List<RegionData> regions = m_Database.GetDefaultHypergridRegions(scopeID);
496
497 foreach (RegionData r in regions)
498 {
499 if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0)
500 ret.Add(RegionData2RegionInfo(r));
501 }
502
503 int hgDefaultRegionsFoundOnline = regions.Count;
504
505 // For now, hypergrid default regions will always be given precedence but we will also return simple default
506 // regions in case no specific hypergrid regions are specified.
507 ret.AddRange(GetDefaultRegions(scopeID));
508
509 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
510
511 m_log.DebugFormat(
512 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
513 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
514
515 return ret;
516 }
517
480 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 518 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
481 { 519 {
482 List<GridRegion> ret = new List<GridRegion>(); 520 List<GridRegion> ret = new List<GridRegion>();
@@ -525,40 +563,41 @@ namespace OpenSim.Services.GridService
525 563
526 private void HandleDeregisterRegion(string module, string[] cmd) 564 private void HandleDeregisterRegion(string module, string[] cmd)
527 { 565 {
528 if (cmd.Length != 4) 566 if (cmd.Length < 4)
529 { 567 {
530 MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>"); 568 MainConsole.Instance.Output("Usage: degregister region id <region-id>+");
531 return; 569 return;
532 } 570 }
533 571
534 string rawRegionUuid = cmd[3]; 572 for (int i = 3; i < cmd.Length; i++)
535 UUID regionUuid;
536
537 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
538 { 573 {
539 MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); 574 string rawRegionUuid = cmd[i];
540 return; 575 UUID regionUuid;
541 }
542 576
543 GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); 577 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
578 {
579 MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid);
580 return;
581 }
544 582
545 if (region == null) 583 GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid);
546 {
547 MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
548 return;
549 }
550 584
551 if (DeregisterRegion(regionUuid)) 585 if (region == null)
552 { 586 {
553 MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); 587 MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
554 } 588 return;
555 else 589 }
556 {
557 // I don't think this can ever occur if we know that the region exists.
558 MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
559 }
560 590
561 return; 591 if (DeregisterRegion(regionUuid))
592 {
593 MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid);
594 }
595 else
596 {
597 // I don't think this can ever occur if we know that the region exists.
598 MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
599 }
600 }
562 } 601 }
563 602
564 private void HandleShowRegions(string module, string[] cmd) 603 private void HandleShowRegions(string module, string[] cmd)
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 8335724..4024295 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Services.GridService
79 { 79 {
80 if (m_DefaultRegion == null) 80 if (m_DefaultRegion == null)
81 { 81 {
82 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); 82 List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID);
83 if (defs != null && defs.Count > 0) 83 if (defs != null && defs.Count > 0)
84 m_DefaultRegion = defs[0]; 84 m_DefaultRegion = defs[0];
85 else 85 else
diff --git a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs b/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
index b1e5e12..bd84123 100644
--- a/OpenSim/Services/GridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/GridService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 97a0afc..f6136b5 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Services.HypergridService
58 private static IUserAgentService m_UserAgentService; 58 private static IUserAgentService m_UserAgentService;
59 private static ISimulationService m_SimulationService; 59 private static ISimulationService m_SimulationService;
60 private static IGridUserService m_GridUserService; 60 private static IGridUserService m_GridUserService;
61 private static IBansService m_BansService;
61 62
62 private static string m_AllowedClients = string.Empty; 63 private static string m_AllowedClients = string.Empty;
63 private static string m_DeniedClients = string.Empty; 64 private static string m_DeniedClients = string.Empty;
@@ -87,6 +88,7 @@ namespace OpenSim.Services.HypergridService
87 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 88 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
88 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 89 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
89 string gridUserService = serverConfig.GetString("GridUserService", String.Empty); 90 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
91 string bansService = serverConfig.GetString("BansService", String.Empty);
90 92
91 // These are mandatory, the others aren't 93 // These are mandatory, the others aren't
92 if (gridService == string.Empty || presenceService == string.Empty) 94 if (gridService == string.Empty || presenceService == string.Empty)
@@ -121,6 +123,8 @@ namespace OpenSim.Services.HypergridService
121 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); 123 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
122 if (gridUserService != string.Empty) 124 if (gridUserService != string.Empty)
123 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 125 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
126 if (bansService != string.Empty)
127 m_BansService = ServerUtils.LoadPlugin<IBansService>(bansService, args);
124 128
125 if (simService != null) 129 if (simService != null)
126 m_SimulationService = simService; 130 m_SimulationService = simService;
@@ -167,7 +171,7 @@ namespace OpenSim.Services.HypergridService
167 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); 171 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName);
168 if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) 172 if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty)
169 { 173 {
170 List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); 174 List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID);
171 if (defs != null && defs.Count > 0) 175 if (defs != null && defs.Count > 0)
172 { 176 {
173 region = defs[0]; 177 region = defs[0];
@@ -223,7 +227,7 @@ namespace OpenSim.Services.HypergridService
223 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9} Teleport Flags {10}", 227 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9} Teleport Flags {10}",
224 aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName, 228 aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName,
225 aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, aCircuit.teleportFlags.ToString()); 229 aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, aCircuit.teleportFlags.ToString());
226 230
227 // 231 //
228 // Check client 232 // Check client
229 // 233 //
@@ -287,17 +291,16 @@ namespace OpenSim.Services.HypergridService
287 } 291 }
288 } 292 }
289 } 293 }
290 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
291 294
292 // 295 //
293 // Foreign agents allowed? Exceptions? 296 // Foreign agents allowed? Exceptions?
294 // 297 //
295 if (account == null) 298 if (account == null)
296 { 299 {
297 bool allowed = m_ForeignAgentsAllowed; 300 bool allowed = m_ForeignAgentsAllowed;
298 301
299 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions)) 302 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
300 allowed = false; 303 allowed = false;
301 304
302 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions)) 305 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
303 allowed = true; 306 allowed = true;
@@ -311,6 +314,20 @@ namespace OpenSim.Services.HypergridService
311 } 314 }
312 } 315 }
313 316
317 //
318 // Is the user banned?
319 // This uses a Ban service that's more powerful than the configs
320 //
321 string uui = (account != null ? aCircuit.AgentID.ToString() : Util.ProduceUserUniversalIdentifier(aCircuit));
322 if (m_BansService != null && m_BansService.IsBanned(uui, aCircuit.IPAddress, aCircuit.Id0, authURL))
323 {
324 reason = "You are banned from this world";
325 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: user {0} is banned", uui);
326 return false;
327 }
328
329 m_log.DebugFormat("[GATEKEEPER SERVICE]: User {0} is ok", aCircuit.Name);
330
314 bool isFirstLogin = false; 331 bool isFirstLogin = false;
315 // 332 //
316 // Login the presence, if it's not there yet (by the login service) 333 // Login the presence, if it's not there yet (by the login service)
@@ -328,7 +345,8 @@ namespace OpenSim.Services.HypergridService
328 aCircuit.firstname, aCircuit.lastname); 345 aCircuit.firstname, aCircuit.lastname);
329 return false; 346 return false;
330 } 347 }
331 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); 348
349 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence {0} is ok", aCircuit.Name);
332 350
333 // Also login foreigners with GridUser service 351 // Also login foreigners with GridUser service
334 if (m_GridUserService != null && account == null) 352 if (m_GridUserService != null && account == null)
@@ -359,7 +377,9 @@ namespace OpenSim.Services.HypergridService
359 reason = "Destination region not found"; 377 reason = "Destination region not found";
360 return false; 378 return false;
361 } 379 }
362 m_log.DebugFormat("[GATEKEEPER SERVICE]: destination ok: {0}", destination.RegionName); 380
381 m_log.DebugFormat(
382 "[GATEKEEPER SERVICE]: Destination {0} is ok for {1}", destination.RegionName, aCircuit.Name);
363 383
364 // 384 //
365 // Adjust the visible name 385 // Adjust the visible name
@@ -393,7 +413,8 @@ namespace OpenSim.Services.HypergridService
393 // Preserve our TeleportFlags we have gathered so-far 413 // Preserve our TeleportFlags we have gathered so-far
394 loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags; 414 loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags;
395 415
396 m_log.DebugFormat("[GATEKEEPER SERVICE]: launching agent {0}", loginFlag); 416 m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0} {1}", aCircuit.Name, loginFlag);
417
397 return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason); 418 return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason);
398 } 419 }
399 420
@@ -402,6 +423,12 @@ namespace OpenSim.Services.HypergridService
402 if (!CheckAddress(aCircuit.ServiceSessionID)) 423 if (!CheckAddress(aCircuit.ServiceSessionID))
403 return false; 424 return false;
404 425
426 if (string.IsNullOrEmpty(aCircuit.IPAddress))
427 {
428 m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address.");
429 return false;
430 }
431
405 string userURL = string.Empty; 432 string userURL = string.Empty;
406 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 433 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
407 userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 434 userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 326e68d..3233caf 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -298,7 +298,7 @@ namespace OpenSim.Services.HypergridService
298 UserAccount user = m_Cache.GetUser(it.CreatorId); 298 UserAccount user = m_Cache.GetUser(it.CreatorId);
299 299
300 // Adjust the creator data 300 // Adjust the creator data
301 if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) 301 if (user != null && it != null && string.IsNullOrEmpty(it.CreatorData))
302 it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName; 302 it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName;
303 } 303 }
304 return it; 304 return it;
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index eecf757..835cde3 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Services.HypergridService
54 LogManager.GetLogger( 54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 private string m_HomeURL; 57// private string m_HomeURL;
58 private IUserAccountService m_UserAccountService; 58 private IUserAccountService m_UserAccountService;
59 private IAvatarService m_AvatarService; 59 private IAvatarService m_AvatarService;
60 60
@@ -96,8 +96,8 @@ namespace OpenSim.Services.HypergridService
96 if (m_AvatarService == null) 96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); 97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98 98
99 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", 99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
100 new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); 100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
101 101
102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
103 } 103 }
@@ -115,6 +115,12 @@ namespace OpenSim.Services.HypergridService
115 { 115 {
116 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 116 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
117 117
118 if (suitcase == null)
119 {
120 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for inventory skeleton", principalID);
121 return null;
122 }
123
118 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); 124 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
119 if (tree == null || (tree != null && tree.Count == 0)) 125 if (tree == null || (tree != null && tree.Count == 0))
120 return null; 126 return null;
@@ -134,6 +140,7 @@ namespace OpenSim.Services.HypergridService
134 public override InventoryCollection GetUserInventory(UUID userID) 140 public override InventoryCollection GetUserInventory(UUID userID)
135 { 141 {
136 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID); 142 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID);
143
137 InventoryCollection userInventory = new InventoryCollection(); 144 InventoryCollection userInventory = new InventoryCollection();
138 userInventory.UserID = userID; 145 userInventory.UserID = userID;
139 userInventory.Folders = new List<InventoryFolderBase>(); 146 userInventory.Folders = new List<InventoryFolderBase>();
@@ -141,6 +148,12 @@ namespace OpenSim.Services.HypergridService
141 148
142 XInventoryFolder suitcase = GetSuitcaseXFolder(userID); 149 XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
143 150
151 if (suitcase == null)
152 {
153 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for user inventory", userID);
154 return null;
155 }
156
144 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); 157 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
145 if (tree == null || (tree != null && tree.Count == 0)) 158 if (tree == null || (tree != null && tree.Count == 0))
146 { 159 {
@@ -182,7 +195,8 @@ namespace OpenSim.Services.HypergridService
182 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 195 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
183 196
184 // Let's find out the local root folder 197 // Let's find out the local root folder
185 XInventoryFolder root = GetRootXFolder(principalID); ; 198 XInventoryFolder root = GetRootXFolder(principalID);
199
186 if (root == null) 200 if (root == null)
187 { 201 {
188 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); 202 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
@@ -199,16 +213,23 @@ namespace OpenSim.Services.HypergridService
199 // In the DB we tag it as type 100, but we use -1 (Unknown) outside 213 // In the DB we tag it as type 100, but we use -1 (Unknown) outside
200 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); 214 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase");
201 if (suitcase == null) 215 if (suitcase == null)
216 {
202 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); 217 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
203 m_Database.StoreFolder(suitcase); 218 }
219 else
220 {
221 m_Database.StoreFolder(suitcase);
204 222
205 // Create System folders 223 // Create System folders
206 CreateSystemFolders(principalID, suitcase.folderID); 224 CreateSystemFolders(principalID, suitcase.folderID);
207 }
208 225
209 SetAsNormalFolder(suitcase); 226 SetAsNormalFolder(suitcase);
210 227
211 return ConvertToOpenSim(suitcase); 228 return ConvertToOpenSim(suitcase);
229 }
230 }
231
232 return null;
212 } 233 }
213 234
214 protected void CreateSystemFolders(UUID principalID, UUID rootID) 235 protected void CreateSystemFolders(UUID principalID, UUID rootID)
@@ -255,6 +276,13 @@ namespace OpenSim.Services.HypergridService
255 { 276 {
256 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); 277 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
257 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 278 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
279
280 if (suitcase == null)
281 {
282 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for child type folder {1}", principalID, type);
283 return null;
284 }
285
258 XInventoryFolder[] folders = m_Database.GetFolders( 286 XInventoryFolder[] folders = m_Database.GetFolders(
259 new string[] { "agentID", "type", "parentFolderID" }, 287 new string[] { "agentID", "type", "parentFolderID" },
260 new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() }); 288 new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() });
@@ -472,6 +500,22 @@ namespace OpenSim.Services.HypergridService
472 return null; 500 return null;
473 } 501 }
474 502
503 private XInventoryFolder GetCurrentOutfitXFolder(UUID userID)
504 {
505 XInventoryFolder root = GetRootXFolder(userID);
506 if (root == null)
507 return null;
508
509 XInventoryFolder[] folders = m_Database.GetFolders(
510 new string[] { "agentID", "type", "parentFolderID" },
511 new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString(), root.folderID.ToString() });
512
513 if (folders.Length == 0)
514 return null;
515
516 return folders[0];
517 }
518
475 private XInventoryFolder GetSuitcaseXFolder(UUID principalID) 519 private XInventoryFolder GetSuitcaseXFolder(UUID principalID)
476 { 520 {
477 // Warp! Root folder for travelers 521 // Warp! Root folder for travelers
@@ -510,6 +554,7 @@ namespace OpenSim.Services.HypergridService
510 if (m_SuitcaseTrees.TryGetValue(principalID, out t)) 554 if (m_SuitcaseTrees.TryGetValue(principalID, out t))
511 return t; 555 return t;
512 556
557 // Get the tree of the suitcase folder
513 t = GetFolderTreeRecursive(folder); 558 t = GetFolderTreeRecursive(folder);
514 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes 559 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes
515 return t; 560 return t;
@@ -546,6 +591,7 @@ namespace OpenSim.Services.HypergridService
546 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) 591 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID)
547 { 592 {
548 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 593 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
594
549 if (suitcase == null) 595 if (suitcase == null)
550 { 596 {
551 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); 597 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
@@ -555,6 +601,9 @@ namespace OpenSim.Services.HypergridService
555 List<XInventoryFolder> tree = new List<XInventoryFolder>(); 601 List<XInventoryFolder> tree = new List<XInventoryFolder>();
556 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder 602 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
557 tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); 603 tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
604 // Also add the Current Outfit folder to the list of available folders
605 tree.Add(GetCurrentOutfitXFolder(principalID));
606
558 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) 607 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
559 { 608 {
560 if (fl.folderID == folderID) return true; 609 if (fl.folderID == folderID) return true;
diff --git a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
index 8d66f1b..0fb60f6 100644
--- a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/HypergridService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index ec76508..b414aca 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32 32
33using OpenSim.Data;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Services.Connectors.Friends; 35using OpenSim.Services.Connectors.Friends;
35using OpenSim.Services.Connectors.Hypergrid; 36using OpenSim.Services.Connectors.Hypergrid;
@@ -50,14 +51,14 @@ namespace OpenSim.Services.HypergridService
50 /// needs to do it for them. 51 /// needs to do it for them.
51 /// Once we have better clients, this shouldn't be needed. 52 /// Once we have better clients, this shouldn't be needed.
52 /// </summary> 53 /// </summary>
53 public class UserAgentService : IUserAgentService 54 public class UserAgentService : UserAgentServiceBase, IUserAgentService
54 { 55 {
55 private static readonly ILog m_log = 56 private static readonly ILog m_log =
56 LogManager.GetLogger( 57 LogManager.GetLogger(
57 MethodBase.GetCurrentMethod().DeclaringType); 58 MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 // This will need to go into a DB table 60 // This will need to go into a DB table
60 static Dictionary<UUID, TravelingAgentInfo> m_TravelingAgents = new Dictionary<UUID, TravelingAgentInfo>(); 61 //static Dictionary<UUID, TravelingAgentInfo> m_Database = new Dictionary<UUID, TravelingAgentInfo>();
61 62
62 static bool m_Initialized = false; 63 static bool m_Initialized = false;
63 64
@@ -86,6 +87,7 @@ namespace OpenSim.Services.HypergridService
86 } 87 }
87 88
88 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector) 89 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector)
90 : base(config)
89 { 91 {
90 // Let's set this always, because we don't know the sequence 92 // Let's set this always, because we don't know the sequence
91 // of instantiations 93 // of instantiations
@@ -146,6 +148,9 @@ namespace OpenSim.Services.HypergridService
146 if (!m_GridName.EndsWith("/")) 148 if (!m_GridName.EndsWith("/"))
147 m_GridName = m_GridName + "/"; 149 m_GridName = m_GridName + "/";
148 150
151 // Finally some cleanup
152 m_Database.DeleteOld();
153
149 } 154 }
150 } 155 }
151 156
@@ -210,10 +215,10 @@ namespace OpenSim.Services.HypergridService
210 return home; 215 return home;
211 } 216 }
212 217
213 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason) 218 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason)
214 { 219 {
215 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 220 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
216 agentCircuit.firstname, agentCircuit.lastname, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI); 221 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
217 222
218 string gridName = gatekeeper.ServerURI; 223 string gridName = gatekeeper.ServerURI;
219 224
@@ -260,12 +265,13 @@ namespace OpenSim.Services.HypergridService
260 265
261 // Generate a new service session 266 // Generate a new service session
262 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); 267 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
263 TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region); 268 TravelingAgentInfo old = null;
269 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
264 270
265 bool success = false; 271 bool success = false;
266 string myExternalIP = string.Empty; 272 string myExternalIP = string.Empty;
267 273
268 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName); 274 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
269 275
270 if (m_GridName == gridName) 276 if (m_GridName == gridName)
271 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); 277 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
@@ -282,23 +288,21 @@ namespace OpenSim.Services.HypergridService
282 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", 288 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
283 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); 289 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
284 290
285 // restore the old travel info 291 if (old != null)
286 lock (m_TravelingAgents) 292 StoreTravelInfo(old);
287 { 293 else
288 if (old == null) 294 m_Database.Delete(agentCircuit.SessionID);
289 m_TravelingAgents.Remove(agentCircuit.SessionID);
290 else
291 m_TravelingAgents[agentCircuit.SessionID] = old;
292 }
293 295
294 return false; 296 return false;
295 } 297 }
296 298
299 // Everything is ok
300
301 // Update the perceived IP Address of our grid
297 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); 302 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
298 // else set the IP addresses associated with this client 303 travel.MyIpAddress = myExternalIP;
299 if (clientIP != null) 304
300 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString(); 305 StoreTravelInfo(travel);
301 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
302 306
303 return true; 307 return true;
304 } 308 }
@@ -306,60 +310,42 @@ namespace OpenSim.Services.HypergridService
306 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) 310 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
307 { 311 {
308 reason = string.Empty; 312 reason = string.Empty;
309 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, null, out reason); 313 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason);
310 } 314 }
311 315
312 private void SetClientIP(UUID sessionID, string ip) 316 TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing)
313 { 317 {
314 if (m_TravelingAgents.ContainsKey(sessionID)) 318 HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID);
315 { 319 existing = null;
316 m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
317 m_TravelingAgents[sessionID].ClientIPAddress = ip;
318 }
319 }
320 320
321 TravelingAgentInfo UpdateTravelInfo(AgentCircuitData agentCircuit, GridRegion region) 321 if (hgt != null)
322 {
323 TravelingAgentInfo travel = new TravelingAgentInfo();
324 TravelingAgentInfo old = null;
325 lock (m_TravelingAgents)
326 { 322 {
327 if (m_TravelingAgents.ContainsKey(agentCircuit.SessionID)) 323 // Very important! Override whatever this agent comes with.
328 { 324 // UserAgentService always sets the IP for every new agent
329 // Very important! Override whatever this agent comes with. 325 // with the original IP address.
330 // UserAgentService always sets the IP for every new agent 326 existing = new TravelingAgentInfo(hgt);
331 // with the original IP address. 327 agentCircuit.IPAddress = existing.ClientIPAddress;
332 agentCircuit.IPAddress = m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress;
333
334 old = m_TravelingAgents[agentCircuit.SessionID];
335 }
336
337 m_TravelingAgents[agentCircuit.SessionID] = travel;
338 } 328 }
329
330 TravelingAgentInfo travel = new TravelingAgentInfo(existing);
331 travel.SessionID = agentCircuit.SessionID;
339 travel.UserID = agentCircuit.AgentID; 332 travel.UserID = agentCircuit.AgentID;
340 travel.GridExternalName = region.ServerURI; 333 travel.GridExternalName = region.ServerURI;
341 travel.ServiceToken = agentCircuit.ServiceSessionID; 334 travel.ServiceToken = agentCircuit.ServiceSessionID;
342 if (old != null)
343 travel.ClientIPAddress = old.ClientIPAddress;
344 335
345 return old; 336 if (fromLogin)
337 travel.ClientIPAddress = agentCircuit.IPAddress;
338
339 StoreTravelInfo(travel);
340
341 return travel;
346 } 342 }
347 343
348 public void LogoutAgent(UUID userID, UUID sessionID) 344 public void LogoutAgent(UUID userID, UUID sessionID)
349 { 345 {
350 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID); 346 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID);
351 347
352 lock (m_TravelingAgents) 348 m_Database.Delete(sessionID);
353 {
354 List<UUID> travels = new List<UUID>();
355 foreach (KeyValuePair<UUID, TravelingAgentInfo> kvp in m_TravelingAgents)
356 if (kvp.Value == null) // do some clean up
357 travels.Add(kvp.Key);
358 else if (kvp.Value.UserID == userID)
359 travels.Add(kvp.Key);
360 foreach (UUID session in travels)
361 m_TravelingAgents.Remove(session);
362 }
363 349
364 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); 350 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
365 if (guinfo != null) 351 if (guinfo != null)
@@ -369,10 +355,11 @@ namespace OpenSim.Services.HypergridService
369 // We need to prevent foreign users with the same UUID as a local user 355 // We need to prevent foreign users with the same UUID as a local user
370 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 356 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
371 { 357 {
372 if (!m_TravelingAgents.ContainsKey(sessionID)) 358 HGTravelingData hgt = m_Database.Get(sessionID);
359 if (hgt == null)
373 return false; 360 return false;
374 361
375 TravelingAgentInfo travel = m_TravelingAgents[sessionID]; 362 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
376 363
377 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower(); 364 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower();
378 } 365 }
@@ -385,29 +372,32 @@ namespace OpenSim.Services.HypergridService
385 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", 372 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
386 sessionID, reportedIP); 373 sessionID, reportedIP);
387 374
388 if (m_TravelingAgents.ContainsKey(sessionID)) 375 HGTravelingData hgt = m_Database.Get(sessionID);
389 { 376 if (hgt == null)
390 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}", 377 return false;
391 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
392 378
393 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || 379 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
394 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed 380
395 } 381 bool result = travel.ClientIPAddress == reportedIP || travel.MyIpAddress == reportedIP; // NATed
396 382
397 return false; 383 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}",
384 reportedIP, travel.ClientIPAddress, travel.MyIpAddress, result);
385
386 return result;
398 } 387 }
399 388
400 public bool VerifyAgent(UUID sessionID, string token) 389 public bool VerifyAgent(UUID sessionID, string token)
401 { 390 {
402 if (m_TravelingAgents.ContainsKey(sessionID)) 391 HGTravelingData hgt = m_Database.Get(sessionID);
392 if (hgt == null)
403 { 393 {
404 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, m_TravelingAgents[sessionID].ServiceToken); 394 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
405 return m_TravelingAgents[sessionID].ServiceToken == token; 395 return false;
406 } 396 }
407 397
408 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID); 398 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
409 399 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, travel.ServiceToken);
410 return false; 400 return travel.ServiceToken == token;
411 } 401 }
412 402
413 [Obsolete] 403 [Obsolete]
@@ -470,17 +460,17 @@ namespace OpenSim.Services.HypergridService
470 } 460 }
471 } 461 }
472 462
473 // Lastly, let's notify the rest who may be online somewhere else 463 //// Lastly, let's notify the rest who may be online somewhere else
474 foreach (string user in usersToBeNotified) 464 //foreach (string user in usersToBeNotified)
475 { 465 //{
476 UUID id = new UUID(user); 466 // UUID id = new UUID(user);
477 if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName) 467 // if (m_Database.ContainsKey(id) && m_Database[id].GridExternalName != m_GridName)
478 { 468 // {
479 string url = m_TravelingAgents[id].GridExternalName; 469 // string url = m_Database[id].GridExternalName;
480 // forward 470 // // forward
481 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url); 471 // m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
482 } 472 // }
483 } 473 //}
484 474
485 // and finally, let's send the online friends 475 // and finally, let's send the online friends
486 if (online) 476 if (online)
@@ -607,16 +597,13 @@ namespace OpenSim.Services.HypergridService
607 597
608 public string LocateUser(UUID userID) 598 public string LocateUser(UUID userID)
609 { 599 {
610 foreach (TravelingAgentInfo t in m_TravelingAgents.Values) 600 HGTravelingData[] hgts = m_Database.GetSessions(userID);
611 { 601 if (hgts == null)
612 if (t == null) 602 return string.Empty;
613 { 603
614 m_log.ErrorFormat("[USER AGENT SERVICE]: Oops! Null TravelingAgentInfo. Please report this on mantis"); 604 foreach (HGTravelingData t in hgts)
615 continue; 605 if (t.Data.ContainsKey("GridExternalName") && !m_GridName.Equals(t.Data["GridExternalName"]))
616 } 606 return t.Data["GridExternalName"];
617 if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
618 return t.GridExternalName;
619 }
620 607
621 return string.Empty; 608 return string.Empty;
622 } 609 }
@@ -687,17 +674,60 @@ namespace OpenSim.Services.HypergridService
687 return exception; 674 return exception;
688 } 675 }
689 676
677 private void StoreTravelInfo(TravelingAgentInfo travel)
678 {
679 if (travel == null)
680 return;
681
682 HGTravelingData hgt = new HGTravelingData();
683 hgt.SessionID = travel.SessionID;
684 hgt.UserID = travel.UserID;
685 hgt.Data = new Dictionary<string, string>();
686 hgt.Data["GridExternalName"] = travel.GridExternalName;
687 hgt.Data["ServiceToken"] = travel.ServiceToken;
688 hgt.Data["ClientIPAddress"] = travel.ClientIPAddress;
689 hgt.Data["MyIPAddress"] = travel.MyIpAddress;
690
691 m_Database.Store(hgt);
692 }
690 #endregion 693 #endregion
691 694
692 } 695 }
693 696
694 class TravelingAgentInfo 697 class TravelingAgentInfo
695 { 698 {
699 public UUID SessionID;
696 public UUID UserID; 700 public UUID UserID;
697 public string GridExternalName = string.Empty; 701 public string GridExternalName = string.Empty;
698 public string ServiceToken = string.Empty; 702 public string ServiceToken = string.Empty;
699 public string ClientIPAddress = string.Empty; // as seen from this user agent service 703 public string ClientIPAddress = string.Empty; // as seen from this user agent service
700 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper 704 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
705
706 public TravelingAgentInfo(HGTravelingData t)
707 {
708 if (t.Data != null)
709 {
710 SessionID = new UUID(t.SessionID);
711 UserID = new UUID(t.UserID);
712 GridExternalName = t.Data["GridExternalName"];
713 ServiceToken = t.Data["ServiceToken"];
714 ClientIPAddress = t.Data["ClientIPAddress"];
715 MyIpAddress = t.Data["MyIPAddress"];
716 }
717 }
718
719 public TravelingAgentInfo(TravelingAgentInfo old)
720 {
721 if (old != null)
722 {
723 SessionID = old.SessionID;
724 UserID = old.UserID;
725 GridExternalName = old.GridExternalName;
726 ServiceToken = old.ServiceToken;
727 ClientIPAddress = old.ClientIPAddress;
728 MyIpAddress = old.MyIpAddress;
729 }
730 }
701 } 731 }
702 732
703} 733}
diff --git a/OpenSim/Services/HypergridService/UserAgentServiceBase.cs b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
new file mode 100644
index 0000000..a00e5a6
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
@@ -0,0 +1,84 @@
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.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace OpenSim.Services.HypergridService
37{
38 public class UserAgentServiceBase : ServiceBase
39 {
40 protected IHGTravelingData m_Database = null;
41
42 public UserAgentServiceBase(IConfigSource config)
43 : base(config)
44 {
45 string dllName = String.Empty;
46 string connString = String.Empty;
47 string realm = "hg_traveling_data";
48
49 //
50 // Try reading the [DatabaseService] section, if it exists
51 //
52 IConfig dbConfig = config.Configs["DatabaseService"];
53 if (dbConfig != null)
54 {
55 if (dllName == String.Empty)
56 dllName = dbConfig.GetString("StorageProvider", String.Empty);
57 if (connString == String.Empty)
58 connString = dbConfig.GetString("ConnectionString", String.Empty);
59 }
60
61 //
62 // [UserAgentService] section overrides [DatabaseService], if it exists
63 //
64 IConfig gridConfig = config.Configs["UserAgentService"];
65 if (gridConfig != null)
66 {
67 dllName = gridConfig.GetString("StorageProvider", dllName);
68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm);
70 }
71
72 //
73 // We tried, but this doesn't exist. We can't proceed.
74 //
75 if (dllName.Equals(String.Empty))
76 throw new Exception("No StorageProvider configured");
77
78 m_Database = LoadPlugin<IHGTravelingData>(dllName, new Object[] { connString, realm });
79 if (m_Database == null)
80 throw new Exception("Could not find a storage interface in the given module");
81
82 }
83 }
84}
diff --git a/OpenSim/Services/Interfaces/IBansService.cs b/OpenSim/Services/Interfaces/IBansService.cs
new file mode 100644
index 0000000..8fd3521
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IBansService.cs
@@ -0,0 +1,48 @@
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;
29
30using OpenSim.Framework;
31using OpenMetaverse;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IBansService
36 {
37 /// <summary>
38 /// Are any of the given arguments banned from the grid?
39 /// </summary>
40 /// <param name="userID"></param>
41 /// <param name="ip"></param>
42 /// <param name="id0"></param>
43 /// <param name="origin"></param>
44 /// <returns></returns>
45 bool IsBanned(string userID, string ip, string id0, string origin);
46 }
47
48}
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 3f4c958..4466222 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -29,9 +29,13 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Net.Sockets; 31using System.Net.Sockets;
32using System.Reflection;
33
32using OpenSim.Framework; 34using OpenSim.Framework;
33using OpenMetaverse; 35using OpenMetaverse;
34 36
37using log4net;
38
35namespace OpenSim.Services.Interfaces 39namespace OpenSim.Services.Interfaces
36{ 40{
37 public interface IGridService 41 public interface IGridService
@@ -97,6 +101,7 @@ namespace OpenSim.Services.Interfaces
97 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax); 101 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
98 102
99 List<GridRegion> GetDefaultRegions(UUID scopeID); 103 List<GridRegion> GetDefaultRegions(UUID scopeID);
104 List<GridRegion> GetDefaultHypergridRegions(UUID scopeID);
100 List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y); 105 List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
101 List<GridRegion> GetHyperlinks(UUID scopeID); 106 List<GridRegion> GetHyperlinks(UUID scopeID);
102 107
@@ -118,6 +123,9 @@ namespace OpenSim.Services.Interfaces
118 123
119 public class GridRegion 124 public class GridRegion
120 { 125 {
126 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
127 private static readonly string LogHeader = "[GRID REGION]";
128
121 /// <summary> 129 /// <summary>
122 /// The port by which http communication occurs with the region 130 /// The port by which http communication occurs with the region
123 /// </summary> 131 /// </summary>
@@ -137,7 +145,10 @@ namespace OpenSim.Services.Interfaces
137 if ( m_serverURI != string.Empty ) { 145 if ( m_serverURI != string.Empty ) {
138 return m_serverURI; 146 return m_serverURI;
139 } else { 147 } else {
140 return "http://" + m_externalHostName + ":" + m_httpPort + "/"; 148 if (m_httpPort == 0)
149 return "http://" + m_externalHostName + "/";
150 else
151 return "http://" + m_externalHostName + ":" + m_httpPort + "/";
141 } 152 }
142 } 153 }
143 set { 154 set {
@@ -173,6 +184,7 @@ namespace OpenSim.Services.Interfaces
173 184
174 /// <summary> 185 /// <summary>
175 /// The location of this region in meters. 186 /// The location of this region in meters.
187 /// DANGER DANGER! Note that this name means something different in RegionInfo.
176 /// </summary> 188 /// </summary>
177 public int RegionLocX 189 public int RegionLocX
178 { 190 {
@@ -181,8 +193,12 @@ namespace OpenSim.Services.Interfaces
181 } 193 }
182 protected int m_regionLocX; 194 protected int m_regionLocX;
183 195
196 public int RegionSizeX { get; set; }
197 public int RegionSizeY { get; set; }
198
184 /// <summary> 199 /// <summary>
185 /// The location of this region in meters. 200 /// The location of this region in meters.
201 /// DANGER DANGER! Note that this name means something different in RegionInfo.
186 /// </summary> 202 /// </summary>
187 public int RegionLocY 203 public int RegionLocY
188 { 204 {
@@ -211,13 +227,18 @@ namespace OpenSim.Services.Interfaces
211 227
212 public GridRegion() 228 public GridRegion()
213 { 229 {
230 RegionSizeX = (int)Constants.RegionSize;
231 RegionSizeY = (int)Constants.RegionSize;
214 m_serverURI = string.Empty; 232 m_serverURI = string.Empty;
215 } 233 }
216 234
235 /*
217 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) 236 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
218 { 237 {
219 m_regionLocX = regionLocX; 238 m_regionLocX = regionLocX;
220 m_regionLocY = regionLocY; 239 m_regionLocY = regionLocY;
240 RegionSizeX = (int)Constants.RegionSize;
241 RegionSizeY = (int)Constants.RegionSize;
221 242
222 m_internalEndPoint = internalEndPoint; 243 m_internalEndPoint = internalEndPoint;
223 m_externalHostName = externalUri; 244 m_externalHostName = externalUri;
@@ -227,16 +248,21 @@ namespace OpenSim.Services.Interfaces
227 { 248 {
228 m_regionLocX = regionLocX; 249 m_regionLocX = regionLocX;
229 m_regionLocY = regionLocY; 250 m_regionLocY = regionLocY;
251 RegionSizeX = (int)Constants.RegionSize;
252 RegionSizeY = (int)Constants.RegionSize;
230 253
231 m_externalHostName = externalUri; 254 m_externalHostName = externalUri;
232 255
233 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); 256 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
234 } 257 }
258 */
235 259
236 public GridRegion(uint xcell, uint ycell) 260 public GridRegion(uint xcell, uint ycell)
237 { 261 {
238 m_regionLocX = (int)(xcell * Constants.RegionSize); 262 m_regionLocX = (int)(xcell * Constants.RegionSize);
239 m_regionLocY = (int)(ycell * Constants.RegionSize); 263 m_regionLocY = (int)(ycell * Constants.RegionSize);
264 RegionSizeX = (int)Constants.RegionSize;
265 RegionSizeY = (int)Constants.RegionSize;
240 } 266 }
241 267
242 public GridRegion(RegionInfo ConvertFrom) 268 public GridRegion(RegionInfo ConvertFrom)
@@ -244,6 +270,8 @@ namespace OpenSim.Services.Interfaces
244 m_regionName = ConvertFrom.RegionName; 270 m_regionName = ConvertFrom.RegionName;
245 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); 271 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
246 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); 272 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
273 RegionSizeX = (int)ConvertFrom.RegionSizeX;
274 RegionSizeY = (int)ConvertFrom.RegionSizeY;
247 m_internalEndPoint = ConvertFrom.InternalEndPoint; 275 m_internalEndPoint = ConvertFrom.InternalEndPoint;
248 m_externalHostName = ConvertFrom.ExternalHostName; 276 m_externalHostName = ConvertFrom.ExternalHostName;
249 m_httpPort = ConvertFrom.HttpPort; 277 m_httpPort = ConvertFrom.HttpPort;
@@ -262,6 +290,8 @@ namespace OpenSim.Services.Interfaces
262 m_regionName = ConvertFrom.RegionName; 290 m_regionName = ConvertFrom.RegionName;
263 m_regionLocX = ConvertFrom.RegionLocX; 291 m_regionLocX = ConvertFrom.RegionLocX;
264 m_regionLocY = ConvertFrom.RegionLocY; 292 m_regionLocY = ConvertFrom.RegionLocY;
293 RegionSizeX = ConvertFrom.RegionSizeX;
294 RegionSizeY = ConvertFrom.RegionSizeY;
265 m_internalEndPoint = ConvertFrom.InternalEndPoint; 295 m_internalEndPoint = ConvertFrom.InternalEndPoint;
266 m_externalHostName = ConvertFrom.ExternalHostName; 296 m_externalHostName = ConvertFrom.ExternalHostName;
267 m_httpPort = ConvertFrom.HttpPort; 297 m_httpPort = ConvertFrom.HttpPort;
@@ -373,6 +403,8 @@ namespace OpenSim.Services.Interfaces
373 kvp["uuid"] = RegionID.ToString(); 403 kvp["uuid"] = RegionID.ToString();
374 kvp["locX"] = RegionLocX.ToString(); 404 kvp["locX"] = RegionLocX.ToString();
375 kvp["locY"] = RegionLocY.ToString(); 405 kvp["locY"] = RegionLocY.ToString();
406 kvp["sizeX"] = RegionSizeX.ToString();
407 kvp["sizeY"] = RegionSizeY.ToString();
376 kvp["regionName"] = RegionName; 408 kvp["regionName"] = RegionName;
377 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); 409 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
378 kvp["serverHttpPort"] = HttpPort.ToString(); 410 kvp["serverHttpPort"] = HttpPort.ToString();
@@ -399,6 +431,16 @@ namespace OpenSim.Services.Interfaces
399 if (kvp.ContainsKey("locY")) 431 if (kvp.ContainsKey("locY"))
400 RegionLocY = Convert.ToInt32((string)kvp["locY"]); 432 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
401 433
434 if (kvp.ContainsKey("sizeX"))
435 RegionSizeX = Convert.ToInt32((string)kvp["sizeX"]);
436 else
437 RegionSizeX = (int)Constants.RegionSize;
438
439 if (kvp.ContainsKey("sizeY"))
440 RegionSizeY = Convert.ToInt32((string)kvp["sizeY"]);
441 else
442 RegionSizeX = (int)Constants.RegionSize;
443
402 if (kvp.ContainsKey("regionName")) 444 if (kvp.ContainsKey("regionName"))
403 RegionName = (string)kvp["regionName"]; 445 RegionName = (string)kvp["regionName"];
404 446
@@ -452,6 +494,9 @@ namespace OpenSim.Services.Interfaces
452 494
453 if (kvp.ContainsKey("Token")) 495 if (kvp.ContainsKey("Token"))
454 Token = kvp["Token"].ToString(); 496 Token = kvp["Token"].ToString();
497
498 // m_log.DebugFormat("{0} New GridRegion. id={1}, loc=<{2},{3}>, size=<{4},{5}>",
499 // LogHeader, RegionID, RegionLocX, RegionLocY, RegionSizeX, RegionSizeY);
455 } 500 }
456 } 501 }
457} 502}
diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs
index 3dc877a..05e175a 100644
--- a/OpenSim/Services/Interfaces/IHypergridServices.cs
+++ b/OpenSim/Services/Interfaces/IHypergridServices.cs
@@ -43,15 +43,9 @@ namespace OpenSim.Services.Interfaces
43 43
44 } 44 }
45 45
46 /// <summary>
47 /// HG1.5 only
48 /// </summary>
49 public interface IUserAgentService 46 public interface IUserAgentService
50 { 47 {
51 // called by login service only 48 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason);
52 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason);
53 // called by simulators
54 bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, out string reason);
55 void LogoutAgent(UUID userID, UUID sessionID); 49 void LogoutAgent(UUID userID, UUID sessionID);
56 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt); 50 GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt);
57 Dictionary<string, object> GetServerURLs(UUID userID); 51 Dictionary<string, object> GetServerURLs(UUID userID);
diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs
index 2848967..588aaaf 100644
--- a/OpenSim/Services/Interfaces/IOfflineIMService.cs
+++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs
@@ -35,7 +35,14 @@ namespace OpenSim.Services.Interfaces
35 public interface IOfflineIMService 35 public interface IOfflineIMService
36 { 36 {
37 List<GridInstantMessage> GetMessages(UUID principalID); 37 List<GridInstantMessage> GetMessages(UUID principalID);
38
38 bool StoreMessage(GridInstantMessage im, out string reason); 39 bool StoreMessage(GridInstantMessage im, out string reason);
40
41 /// <summary>
42 /// Delete messages to or from this user (or group).
43 /// </summary>
44 /// <param name="userID">A user or group ID</param>
45 void DeleteMessages(UUID userID);
39 } 46 }
40 47
41 public class OfflineIMDataUtils 48 public class OfflineIMDataUtils
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index a963b8e..1c82b3e 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -75,8 +75,6 @@ namespace OpenSim.Services.Interfaces
75 /// <returns></returns> 75 /// <returns></returns>
76 bool UpdateAgent(GridRegion destination, AgentPosition data); 76 bool UpdateAgent(GridRegion destination, AgentPosition data);
77 77
78 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
79
80 bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason); 78 bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason);
81 79
82 /// <summary> 80 /// <summary>
@@ -90,20 +88,12 @@ namespace OpenSim.Services.Interfaces
90 bool ReleaseAgent(UUID originRegion, UUID id, string uri); 88 bool ReleaseAgent(UUID originRegion, UUID id, string uri);
91 89
92 /// <summary> 90 /// <summary>
93 /// Close child agent.
94 /// </summary>
95 /// <param name="regionHandle"></param>
96 /// <param name="id"></param>
97 /// <returns></returns>
98 bool CloseChildAgent(GridRegion destination, UUID id);
99
100 /// <summary>
101 /// Close agent. 91 /// Close agent.
102 /// </summary> 92 /// </summary>
103 /// <param name="regionHandle"></param> 93 /// <param name="regionHandle"></param>
104 /// <param name="id"></param> 94 /// <param name="id"></param>
105 /// <returns></returns> 95 /// <returns></returns>
106 bool CloseAgent(GridRegion destination, UUID id); 96 bool CloseAgent(GridRegion destination, UUID id, string auth_token);
107 97
108 #endregion Agents 98 #endregion Agents
109 99
diff --git a/OpenSim/Services/Interfaces/IUserProfilesService.cs b/OpenSim/Services/Interfaces/IUserProfilesService.cs
new file mode 100644
index 0000000..319d307
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IUserProfilesService.cs
@@ -0,0 +1,75 @@
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 OpenSim.Framework;
30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IUserProfilesService
36 {
37 #region Classifieds
38 OSD AvatarClassifiedsRequest(UUID creatorId);
39 bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result);
40 bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result);
41 bool ClassifiedDelete(UUID recordId);
42 #endregion Classifieds
43
44 #region Picks
45 OSD AvatarPicksRequest(UUID creatorId);
46 bool PickInfoRequest(ref UserProfilePick pick, ref string result);
47 bool PicksUpdate(ref UserProfilePick pick, ref string result);
48 bool PicksDelete(UUID pickId);
49 #endregion Picks
50
51 #region Notes
52 bool AvatarNotesRequest(ref UserProfileNotes note);
53 bool NotesUpdate(ref UserProfileNotes note, ref string result);
54 #endregion Notes
55
56 #region Profile Properties
57 bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result);
58 bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result);
59 #endregion Profile Properties
60
61 #region Interests
62 bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result);
63 #endregion Interests
64
65 #region Utility
66 OSD AvatarImageAssetsRequest(UUID avatarId);
67 #endregion Utility
68
69 #region UserData
70 bool RequestUserAppData(ref UserAppData prop, ref string result);
71 bool SetUserAppData(UserAppData prop, ref string result);
72 #endregion UserData
73 }
74}
75
diff --git a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs b/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs
index 47ece75..f7c8cc1 100644
--- a/OpenSim/Services/Interfaces/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/Interfaces/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs b/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs
index bfae81f..fd8707b 100644
--- a/OpenSim/Services/InventoryService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/InventoryService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index e2f947c..f641955 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -196,6 +196,7 @@ namespace OpenSim.Services.LLLoginService
196 private BuddyList m_buddyList = null; 196 private BuddyList m_buddyList = null;
197 197
198 private string currency; 198 private string currency;
199 private string classifiedFee;
199 200
200 static LLLoginResponse() 201 static LLLoginResponse()
201 { 202 {
@@ -233,7 +234,7 @@ namespace OpenSim.Services.LLLoginService
233 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, 234 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
234 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message, 235 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
235 GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency, 236 GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency,
236 string DSTZone, UUID realID) 237 string DSTZone, string destinationsURL, string avatarsURL, UUID realID, string classifiedFee)
237 : this() 238 : this()
238 { 239 {
239 FillOutInventoryData(invSkel, libService); 240 FillOutInventoryData(invSkel, libService);
@@ -253,14 +254,18 @@ namespace OpenSim.Services.LLLoginService
253 MapTileURL = mapTileURL; 254 MapTileURL = mapTileURL;
254 ProfileURL = profileURL; 255 ProfileURL = profileURL;
255 OpenIDURL = openIDURL; 256 OpenIDURL = openIDURL;
257 DestinationsURL = destinationsURL;
258 AvatarsURL = avatarsURL;
256 259
257 SearchURL = searchURL; 260 SearchURL = searchURL;
258 Currency = currency; 261 Currency = currency;
262 ClassifiedFee = classifiedFee;
259 263
260 FillOutHomeData(pinfo, home); 264 FillOutHomeData(pinfo, home);
261 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); 265 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
262 266
263 FillOutRegionData(destination); 267 FillOutRegionData(destination);
268 // m_log.DebugFormat("[LOGIN RESPONSE] LLLoginResponse create. sizeX=<{0},{1}>", RegionSizeX, RegionSizeY);
264 269
265 FillOutSeedCap(aCircuit, destination, clientIP); 270 FillOutSeedCap(aCircuit, destination, clientIP);
266 271
@@ -387,6 +392,8 @@ namespace OpenSim.Services.LLLoginService
387 SimPort = (uint)endPoint.Port; 392 SimPort = (uint)endPoint.Port;
388 RegionX = (uint)destination.RegionLocX; 393 RegionX = (uint)destination.RegionLocX;
389 RegionY = (uint)destination.RegionLocY; 394 RegionY = (uint)destination.RegionLocY;
395 RegionSizeX = destination.RegionSizeX;
396 RegionSizeY = destination.RegionSizeY;
390 } 397 }
391 398
392 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) 399 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient)
@@ -470,6 +477,7 @@ namespace OpenSim.Services.LLLoginService
470 searchURL = String.Empty; 477 searchURL = String.Empty;
471 478
472 currency = String.Empty; 479 currency = String.Empty;
480 ClassifiedFee = "0";
473 } 481 }
474 482
475 483
@@ -533,6 +541,9 @@ namespace OpenSim.Services.LLLoginService
533 responseData["message"] = welcomeMessage; 541 responseData["message"] = welcomeMessage;
534 responseData["region_x"] = (Int32)(RegionX); 542 responseData["region_x"] = (Int32)(RegionX);
535 responseData["region_y"] = (Int32)(RegionY); 543 responseData["region_y"] = (Int32)(RegionY);
544 responseData["region_size_x"] = (Int32)RegionSizeX;
545 responseData["region_size_y"] = (Int32)RegionSizeY;
546 // m_log.DebugFormat("[LOGIN RESPONSE] returning sizeX=<{0},{1}>", RegionSizeX, RegionSizeY);
536 547
537 if (searchURL != String.Empty) 548 if (searchURL != String.Empty)
538 responseData["search"] = searchURL; 549 responseData["search"] = searchURL;
@@ -543,6 +554,12 @@ namespace OpenSim.Services.LLLoginService
543 if (profileURL != String.Empty) 554 if (profileURL != String.Empty)
544 responseData["profile-server-url"] = profileURL; 555 responseData["profile-server-url"] = profileURL;
545 556
557 if (DestinationsURL != String.Empty)
558 responseData["destination_guide_url"] = DestinationsURL;
559
560 if (AvatarsURL != String.Empty)
561 responseData["avatar_picker_url"] = AvatarsURL;
562
546 // We need to send an openid_token back in the response too 563 // We need to send an openid_token back in the response too
547 if (openIDURL != String.Empty) 564 if (openIDURL != String.Empty)
548 responseData["openid_url"] = openIDURL; 565 responseData["openid_url"] = openIDURL;
@@ -557,6 +574,9 @@ namespace OpenSim.Services.LLLoginService
557 // responseData["real_currency"] = currency; 574 // responseData["real_currency"] = currency;
558 responseData["currency"] = currency; 575 responseData["currency"] = currency;
559 } 576 }
577
578 if (ClassifiedFee != String.Empty)
579 responseData["classified_fee"] = ClassifiedFee;
560 580
561 responseData["login"] = "true"; 581 responseData["login"] = "true";
562 582
@@ -662,6 +682,9 @@ namespace OpenSim.Services.LLLoginService
662 if (searchURL != String.Empty) 682 if (searchURL != String.Empty)
663 map["search"] = OSD.FromString(searchURL); 683 map["search"] = OSD.FromString(searchURL);
664 684
685 if (ClassifiedFee != String.Empty)
686 map["classified_fee"] = OSD.FromString(ClassifiedFee);
687
665 if (m_buddyList != null) 688 if (m_buddyList != null)
666 { 689 {
667 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); 690 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray());
@@ -917,6 +940,9 @@ namespace OpenSim.Services.LLLoginService
917 set { regionY = value; } 940 set { regionY = value; }
918 } 941 }
919 942
943 public int RegionSizeX { get; private set; }
944 public int RegionSizeY { get; private set; }
945
920 public string SunTexture 946 public string SunTexture
921 { 947 {
922 get { return sunTexture; } 948 get { return sunTexture; }
@@ -1073,6 +1099,22 @@ namespace OpenSim.Services.LLLoginService
1073 set { currency = value; } 1099 set { currency = value; }
1074 } 1100 }
1075 1101
1102 public string ClassifiedFee
1103 {
1104 get { return classifiedFee; }
1105 set { classifiedFee = value; }
1106 }
1107
1108 public string DestinationsURL
1109 {
1110 get; set;
1111 }
1112
1113 public string AvatarsURL
1114 {
1115 get; set;
1116 }
1117
1076 #endregion 1118 #endregion
1077 1119
1078 public class UserInfo 1120 public class UserInfo
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index ede2353..ed62c43 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Services.LLLoginService
50 public class LLLoginService : ILoginService 50 public class LLLoginService : ILoginService
51 { 51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private static readonly string LogHeader = "[LLOGIN SERVICE]";
54
53 private static bool Initialized = false; 55 private static bool Initialized = false;
54 56
55 protected IUserAccountService m_UserAccountService; 57 protected IUserAccountService m_UserAccountService;
@@ -78,6 +80,9 @@ namespace OpenSim.Services.LLLoginService
78 protected string m_OpenIDURL; 80 protected string m_OpenIDURL;
79 protected string m_SearchURL; 81 protected string m_SearchURL;
80 protected string m_Currency; 82 protected string m_Currency;
83 protected string m_ClassifiedFee;
84 protected string m_DestinationGuide;
85 protected string m_AvatarPicker;
81 86
82 protected string m_AllowedClients; 87 protected string m_AllowedClients;
83 protected string m_DeniedClients; 88 protected string m_DeniedClients;
@@ -117,6 +122,9 @@ namespace OpenSim.Services.LLLoginService
117 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty); 122 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);
118 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); 123 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
119 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); 124 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
125 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty);
126 m_DestinationGuide = m_LoginServerConfig.GetString ("DestinationGuide", string.Empty);
127 m_AvatarPicker = m_LoginServerConfig.GetString ("AvatarPicker", string.Empty);
120 128
121 m_AllowedClients = m_LoginServerConfig.GetString("AllowedClients", string.Empty); 129 m_AllowedClients = m_LoginServerConfig.GetString("AllowedClients", string.Empty);
122 m_DeniedClients = m_LoginServerConfig.GetString("DeniedClients", string.Empty); 130 m_DeniedClients = m_LoginServerConfig.GetString("DeniedClients", string.Empty);
@@ -391,6 +399,7 @@ namespace OpenSim.Services.LLLoginService
391 if (guinfo == null) 399 if (guinfo == null)
392 { 400 {
393 // something went wrong, make something up, so that we don't have to test this anywhere else 401 // something went wrong, make something up, so that we don't have to test this anywhere else
402 m_log.DebugFormat("{0} Failed to fetch GridUserInfo. Creating empty GridUserInfo as home", LogHeader);
394 guinfo = new GridUserInfo(); 403 guinfo = new GridUserInfo();
395 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); 404 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
396 } 405 }
@@ -461,7 +470,8 @@ namespace OpenSim.Services.LLLoginService
461 = new LLLoginResponse( 470 = new LLLoginResponse(
462 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, 471 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
463 where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, 472 where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP,
464 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone, realID); 473 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
474 m_DestinationGuide, m_AvatarPicker, realID, m_ClassifiedFee);
465 475
466 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); 476 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
467 477
@@ -934,7 +944,7 @@ namespace OpenSim.Services.LLLoginService
934 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) 944 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
935 { 945 {
936 m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); 946 m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName);
937 if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, clientIP, out reason)) 947 if (m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, true, out reason))
938 return true; 948 return true;
939 return false; 949 return false;
940 } 950 }
diff --git a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs b/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs
index 0a6daee..c373351 100644
--- a/OpenSim/Services/LLLoginService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/LLLoginService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs
index e2f256f..31e147b 100644
--- a/OpenSim/Services/MapImageService/MapImageService.cs
+++ b/OpenSim/Services/MapImageService/MapImageService.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Services.MapImageService
86 { 86 {
87 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH); 87 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH);
88 FillImage(waterTile, m_Watercolor); 88 FillImage(waterTile, m_Watercolor);
89 waterTile.Save(m_WaterTileFile); 89 waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg);
90 } 90 }
91 } 91 }
92 } 92 }
diff --git a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs b/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs
index 19936e5..edadb26 100644
--- a/OpenSim/Services/MapImageService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/MapImageService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs b/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs
index 5d433df..3bfd1fc 100644
--- a/OpenSim/Services/PresenceService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/PresenceService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index 43fa04b..bef1691 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -46,12 +46,66 @@ namespace OpenSim.Services.UserAccountService
46 46
47 public GridUserService(IConfigSource config) : base(config) 47 public GridUserService(IConfigSource config) : base(config)
48 { 48 {
49 m_log.Debug("[USER GRID SERVICE]: Starting user grid service"); 49 m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
50
51 MainConsole.Instance.Commands.AddCommand(
52 "Users", false,
53 "show grid users online",
54 "show grid users online",
55 "Show number of grid users registered as online.",
56 "This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n."
57 + "For this reason, users online for more than 5 days are not currently counted",
58 HandleShowGridUsersOnline);
59 }
60
61 protected void HandleShowGridUsersOnline(string module, string[] cmdparams)
62 {
63// if (cmdparams.Length != 4)
64// {
65// MainConsole.Instance.Output("Usage: show grid users online");
66// return;
67// }
68
69// int onlineCount;
70 int onlineRecentlyCount = 0;
71
72 DateTime now = DateTime.UtcNow;
73
74 foreach (GridUserData gu in m_Database.GetAll(""))
75 {
76 if (bool.Parse(gu.Data["Online"]))
77 {
78// onlineCount++;
79
80 int unixLoginTime = int.Parse(gu.Data["Login"]);
81
82 if ((now - Util.ToDateTime(unixLoginTime)).Days < 5)
83 onlineRecentlyCount++;
84 }
85 }
86
87 MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount);
50 } 88 }
51 89
52 public virtual GridUserInfo GetGridUserInfo(string userID) 90 public virtual GridUserInfo GetGridUserInfo(string userID)
53 { 91 {
54 GridUserData d = m_Database.Get(userID); 92 GridUserData d = null;
93 if (userID.Length > 36) // it's a UUI
94 d = m_Database.Get(userID);
95 else // it's a UUID
96 {
97 GridUserData[] ds = m_Database.GetAll(userID);
98 if (ds == null)
99 return null;
100
101 if (ds.Length > 0)
102 {
103 d = ds[0];
104 foreach (GridUserData dd in ds)
105 if (dd.UserID.Length > d.UserID.Length) // find the longest
106 d = dd;
107 }
108 }
55 109
56 if (d == null) 110 if (d == null)
57 return null; 111 return null;
@@ -73,7 +127,7 @@ namespace OpenSim.Services.UserAccountService
73 return info; 127 return info;
74 } 128 }
75 129
76 public GridUserInfo[] GetGridUserInfo(string[] userIDs) 130 public virtual GridUserInfo[] GetGridUserInfo(string[] userIDs)
77 { 131 {
78 List<GridUserInfo> ret = new List<GridUserInfo>(); 132 List<GridUserInfo> ret = new List<GridUserInfo>();
79 133
@@ -140,7 +194,8 @@ namespace OpenSim.Services.UserAccountService
140 194
141 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 195 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
142 { 196 {
143 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); 197// m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID);
198
144 GridUserData d = m_Database.Get(userID); 199 GridUserData d = m_Database.Get(userID);
145 if (d == null) 200 if (d == null)
146 { 201 {
diff --git a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs
index e7d2d6f..16ae6bd 100644
--- a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/UserAccountService/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.6.*")] 32[assembly: AssemblyVersion("0.8.0.*")]
33 33
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
new file mode 100644
index 0000000..038e993
--- /dev/null
+++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
@@ -0,0 +1,262 @@
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.Reflection;
30using System.Text;
31using Nini.Config;
32using log4net;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.UserAccountService;
36using OpenSim.Data;
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39using OpenSim.Framework;
40using OpenSim.Services.UserAccountService;
41
42namespace OpenSim.Services.ProfilesService
43{
44 public class UserProfilesService: UserProfilesServiceBase, IUserProfilesService
45 {
46 static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 IUserAccountService userAccounts;
51 IAuthenticationService authService;
52
53 public UserProfilesService(IConfigSource config, string configName):
54 base(config, configName)
55 {
56 IConfig Config = config.Configs[configName];
57 if (Config == null)
58 {
59 m_log.Warn("[PROFILES]: No configuration found!");
60 return;
61 }
62 Object[] args = null;
63
64 args = new Object[] { config };
65 string accountService = Config.GetString("UserAccountService", String.Empty);
66 if (accountService != string.Empty)
67 userAccounts = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
68
69 args = new Object[] { config };
70 string authServiceConfig = Config.GetString("AuthenticationServiceModule", String.Empty);
71 if (accountService != string.Empty)
72 authService = ServerUtils.LoadPlugin<IAuthenticationService>(authServiceConfig, args);
73 }
74
75 #region Classifieds
76 public OSD AvatarClassifiedsRequest(UUID creatorId)
77 {
78 OSDArray records = ProfilesData.GetClassifiedRecords(creatorId);
79
80 return records;
81 }
82
83 public bool ClassifiedUpdate(UserClassifiedAdd ad, ref string result)
84 {
85 if(!ProfilesData.UpdateClassifiedRecord(ad, ref result))
86 {
87 return false;
88 }
89 result = "success";
90 return true;
91 }
92
93 public bool ClassifiedDelete(UUID recordId)
94 {
95 if(ProfilesData.DeleteClassifiedRecord(recordId))
96 return true;
97
98 return false;
99 }
100
101 public bool ClassifiedInfoRequest(ref UserClassifiedAdd ad, ref string result)
102 {
103 if(ProfilesData.GetClassifiedInfo(ref ad, ref result))
104 return true;
105
106 return false;
107 }
108 #endregion Classifieds
109
110 #region Picks
111 public OSD AvatarPicksRequest(UUID creatorId)
112 {
113 OSDArray records = ProfilesData.GetAvatarPicks(creatorId);
114
115 return records;
116 }
117
118 public bool PickInfoRequest(ref UserProfilePick pick, ref string result)
119 {
120 pick = ProfilesData.GetPickInfo(pick.CreatorId, pick.PickId);
121 result = "OK";
122 return true;
123 }
124
125 public bool PicksUpdate(ref UserProfilePick pick, ref string result)
126 {
127 return ProfilesData.UpdatePicksRecord(pick);
128 }
129
130 public bool PicksDelete(UUID pickId)
131 {
132 return ProfilesData.DeletePicksRecord(pickId);
133 }
134 #endregion Picks
135
136 #region Notes
137 public bool AvatarNotesRequest(ref UserProfileNotes note)
138 {
139 return ProfilesData.GetAvatarNotes(ref note);
140 }
141
142 public bool NotesUpdate(ref UserProfileNotes note, ref string result)
143 {
144 return ProfilesData.UpdateAvatarNotes(ref note, ref result);
145 }
146 #endregion Notes
147
148 #region Profile Properties
149 public bool AvatarPropertiesRequest(ref UserProfileProperties prop, ref string result)
150 {
151 return ProfilesData.GetAvatarProperties(ref prop, ref result);
152 }
153
154 public bool AvatarPropertiesUpdate(ref UserProfileProperties prop, ref string result)
155 {
156 return ProfilesData.UpdateAvatarProperties(ref prop, ref result);
157 }
158 #endregion Profile Properties
159
160 #region Interests
161 public bool AvatarInterestsUpdate(UserProfileProperties prop, ref string result)
162 {
163 return ProfilesData.UpdateAvatarInterests(prop, ref result);
164 }
165 #endregion Interests
166
167 /*
168 #region User Preferences
169 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result)
170 {
171 if(string.IsNullOrEmpty(pref.EMail))
172 {
173 UserAccount account = new UserAccount();
174 if(userAccounts is UserAccountService.UserAccountService)
175 {
176 try
177 {
178 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
179 if(string.IsNullOrEmpty(account.Email))
180 {
181 result = "No Email address on record!";
182 return false;
183 }
184 else
185 pref.EMail = account.Email;
186 }
187 catch
188 {
189 m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account");
190 result = "Missing Email address!";
191 return false;
192 }
193 }
194 else
195 {
196 m_log.Info ("[PROFILES]: UserAccountService: Could not get user account");
197 result = "Missing Email address!";
198 return false;
199 }
200 }
201 return ProfilesData.UpdateUserPreferences(ref pref, ref result);
202 }
203
204 public bool UserPreferencesRequest(ref UserPreferences pref, ref string result)
205 {
206 if(string.IsNullOrEmpty(pref.EMail))
207 {
208 UserAccount account = new UserAccount();
209 if(userAccounts is UserAccountService.UserAccountService)
210 {
211 try
212 {
213 account = userAccounts.GetUserAccount(UUID.Zero, pref.UserId);
214 if(string.IsNullOrEmpty(account.Email))
215 {
216 result = "No Email address on record!";
217 return false;
218 }
219 else
220 pref.EMail = account.Email;
221 }
222 catch
223 {
224 m_log.Info ("[PROFILES]: UserAccountService Exception: Could not get user account");
225 result = "Missing Email address!";
226 return false;
227 }
228 }
229 else
230 {
231 m_log.Info ("[PROFILES]: UserAccountService: Could not get user account");
232 result = "Missing Email address!";
233 return false;
234 }
235 }
236 return ProfilesData.GetUserPreferences(ref pref, ref result);
237 }
238 #endregion User Preferences
239 */
240
241 #region Utility
242 public OSD AvatarImageAssetsRequest(UUID avatarId)
243 {
244 OSDArray records = ProfilesData.GetUserImageAssets(avatarId);
245 return records;
246 }
247 #endregion Utility
248
249 #region UserData
250 public bool RequestUserAppData(ref UserAppData prop, ref string result)
251 {
252 return ProfilesData.GetUserAppData(ref prop, ref result);
253 }
254
255 public bool SetUserAppData(UserAppData prop, ref string result)
256 {
257 return true;
258 }
259 #endregion UserData
260 }
261}
262
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
new file mode 100644
index 0000000..927f7c9
--- /dev/null
+++ b/OpenSim/Services/UserProfilesService/UserProfilesServiceBase.cs
@@ -0,0 +1,86 @@
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.Reflection;
30using Nini.Config;
31using log4net;
32using OpenSim.Services.Base;
33using OpenSim.Data;
34
35namespace OpenSim.Services.ProfilesService
36{
37 public class UserProfilesServiceBase: ServiceBase
38 {
39 static readonly ILog m_log =
40 LogManager.GetLogger(
41 MethodBase.GetCurrentMethod().DeclaringType);
42
43 public IProfilesData ProfilesData;
44
45 public string ConfigName
46 {
47 get; private set;
48 }
49
50 public UserProfilesServiceBase(IConfigSource config, string configName):
51 base(config)
52 {
53 if(string.IsNullOrEmpty(configName))
54 {
55 m_log.WarnFormat("[PROFILES]: Configuration section not given!");
56 return;
57 }
58
59 string dllName = String.Empty;
60 string connString = null;
61 string realm = String.Empty;
62
63 IConfig dbConfig = config.Configs["DatabaseService"];
64 if (dbConfig != null)
65 {
66 if (dllName == String.Empty)
67 dllName = dbConfig.GetString("StorageProvider", String.Empty);
68 if (string.IsNullOrEmpty(connString))
69 connString = dbConfig.GetString("ConnectionString", String.Empty);
70 }
71
72 IConfig ProfilesConfig = config.Configs[configName];
73 if (ProfilesConfig != null)
74 {
75 connString = ProfilesConfig.GetString("ConnectionString", connString);
76 realm = ProfilesConfig.GetString("Realm", realm);
77 }
78
79 ProfilesData = LoadPlugin<IProfilesData>(dllName, new Object[] { connString });
80 if (ProfilesData == null)
81 throw new Exception("Could not find a storage interface in the given module");
82
83 }
84 }
85}
86