aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs153
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs116
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs47
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs46
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs34
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs100
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs9
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs57
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs3
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs28
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs131
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs84
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs38
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs50
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs137
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs86
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs74
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs10
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs7
22 files changed, 919 insertions, 313 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs
new file mode 100644
index 0000000..41ae53f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/LocalAgentPreferencesServiceConnector.cs
@@ -0,0 +1,153 @@
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.Generic;
30using System.Reflection;
31using log4net;
32using Mono.Addins;
33using Nini.Config;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces;
38
39using OpenMetaverse;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.AgentPreferences
42{
43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAgentPreferencesServicesConnector")]
44 public class LocalAgentPreferencesServicesConnector : ISharedRegionModule, IAgentPreferencesService
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private IAgentPreferencesService m_AgentPreferencesService;
49 private bool m_Enabled = false;
50
51 #region ISharedRegionModule
52
53 public Type ReplaceableInterface
54 {
55 get { return null; }
56 }
57
58 public string Name
59 {
60 get { return "LocalAgentPreferencesServicesConnector"; }
61 }
62
63 public void Initialise(IConfigSource source)
64 {
65 IConfig moduleConfig = source.Configs["Modules"];
66 if (moduleConfig != null)
67 {
68 string name = moduleConfig.GetString("AgentPreferencesServices", "");
69 if (name == Name)
70 {
71 IConfig userConfig = source.Configs["AgentPreferencesService"];
72 if (userConfig == null)
73 {
74 m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini");
75 return;
76 }
77
78 string serviceDll = userConfig.GetString("LocalServiceModule", String.Empty);
79
80 if (String.IsNullOrEmpty(serviceDll))
81 {
82 m_log.Error("[AGENT PREFERENCES CONNECTOR]: No AgentPreferencesModule named in section AgentPreferencesService");
83 return;
84 }
85
86 Object[] args = new Object[] { source };
87 m_AgentPreferencesService = ServerUtils.LoadPlugin<IAgentPreferencesService>(serviceDll, args);
88
89 if (m_AgentPreferencesService == null)
90 {
91 m_log.Error("[AGENT PREFERENCES CONNECTOR]: Can't load agent preferences service");
92 return;
93 }
94 m_Enabled = true;
95 m_log.Info("[AGENT PREFERENCES CONNECTOR]: Local agent preferences connector enabled");
96 }
97 }
98 }
99
100 public void PostInitialise()
101 {
102 if (!m_Enabled)
103 return;
104 }
105
106 public void Close()
107 {
108 if (!m_Enabled)
109 return;
110 }
111
112 public void AddRegion(Scene scene)
113 {
114 if (!m_Enabled)
115 return;
116
117 scene.RegisterModuleInterface<IAgentPreferencesService>(this);
118 }
119
120 public void RemoveRegion(Scene scene)
121 {
122 if (!m_Enabled)
123 return;
124 }
125
126 public void RegionLoaded(Scene scene)
127 {
128 if (!m_Enabled)
129 return;
130 }
131
132 #endregion ISharedRegionModule
133
134 #region IAgentPreferencesService
135
136 public AgentPrefs GetAgentPreferences(UUID principalID)
137 {
138 return m_AgentPreferencesService.GetAgentPreferences(principalID);
139 }
140
141 public bool StoreAgentPreferences(AgentPrefs data)
142 {
143 return m_AgentPreferencesService.StoreAgentPreferences(data);
144 }
145
146 public string GetLang(UUID principalID)
147 {
148 return m_AgentPreferencesService.GetLang(principalID);
149 }
150
151 #endregion IAgentPreferencesService
152 }
153}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs
new file mode 100644
index 0000000..ad9544a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/AgentPreferences/RemoteAgentPreferencesServiceConnector.cs
@@ -0,0 +1,116 @@
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
28
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base;
36using OpenSim.Services.Interfaces;
37using OpenSim.Services.Connectors;
38
39using OpenMetaverse;
40using log4net;
41using Mono.Addins;
42using Nini.Config;
43
44namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.AgentPreferences
45{
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAgentPreferencesServicesConnector")]
47 public class RemoteAgentPreferencesServicesConnector : AgentPreferencesServicesConnector,
48 ISharedRegionModule, IAgentPreferencesService
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private bool m_Enabled = false;
53
54 public Type ReplaceableInterface
55 {
56 get { return null; }
57 }
58
59 public string Name
60 {
61 get { return "RemoteAgentPreferencesServicesConnector"; }
62 }
63
64 public override void Initialise(IConfigSource source)
65 {
66 IConfig moduleConfig = source.Configs["Modules"];
67 if (moduleConfig != null)
68 {
69 string name = moduleConfig.GetString("AgentPreferencesServices", "");
70 if (name == Name)
71 {
72 IConfig userConfig = source.Configs["AgentPreferencesService"];
73 if (userConfig == null)
74 {
75 m_log.Error("[AGENT PREFERENCES CONNECTOR]: AgentPreferencesService missing from OpenSim.ini");
76 return;
77 }
78
79 m_Enabled = true;
80
81 base.Initialise(source);
82
83 m_log.Info("[AGENT PREFERENCES CONNECTOR]: Remote agent preferences enabled");
84 }
85 }
86 }
87
88 public void PostInitialise()
89 {
90 /* no op */
91 }
92
93 public void Close()
94 {
95 /* no op */
96 }
97
98 public void AddRegion(Scene scene)
99 {
100 if (!m_Enabled)
101 return;
102
103 scene.RegisterModuleInterface<IAgentPreferencesService>(this);
104 }
105
106 public void RemoveRegion(Scene scene)
107 {
108 /* no op */
109 }
110
111 public void RegionLoaded(Scene scene)
112 {
113 /* no op */
114 }
115 }
116} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
index d221d68..7fcfc74 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs
@@ -69,6 +69,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
69 get { return "HGAssetBroker"; } 69 get { return "HGAssetBroker"; }
70 } 70 }
71 71
72 public HGAssetBroker() {}
73
74 public HGAssetBroker(IConfigSource config)
75 {
76 Initialise(config);
77 }
78
72 public void Initialise(IConfigSource source) 79 public void Initialise(IConfigSource source)
73 { 80 {
74 IConfig moduleConfig = source.Configs["Modules"]; 81 IConfig moduleConfig = source.Configs["Modules"];
@@ -288,7 +295,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
288 295
289 if (asset != null) 296 if (asset != null)
290 { 297 {
291 Util.FireAndForget(delegate { handler(id, sender, asset); }); 298 Util.FireAndForget(delegate { handler(id, sender, asset); }, null, "HGAssetBroker.GotFromCache");
292 return true; 299 return true;
293 } 300 }
294 301
@@ -312,6 +319,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
312 } 319 }
313 } 320 }
314 321
322 public virtual bool[] AssetsExist(string[] ids)
323 {
324 int numHG = 0;
325 foreach (string id in ids)
326 {
327 if (IsHG(id))
328 ++numHG;
329 }
330
331 if (numHG == 0)
332 return m_GridService.AssetsExist(ids);
333 else if (numHG == ids.Length)
334 return m_HGService.AssetsExist(ids);
335 else
336 throw new Exception("[HG ASSET CONNECTOR]: AssetsExist: all the assets must be either local or foreign");
337 }
338
315 public string Store(AssetBase asset) 339 public string Store(AssetBase asset)
316 { 340 {
317 bool isHG = IsHG(asset.ID); 341 bool isHG = IsHG(asset.ID);
@@ -322,14 +346,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
322 // a copy of the local asset. 346 // a copy of the local asset.
323 m_Cache.Cache(asset); 347 m_Cache.Cache(asset);
324 348
325 if (asset.Temporary || asset.Local) 349 if (asset.Local)
326 { 350 {
327 if (m_Cache != null) 351 if (m_Cache != null)
328 m_Cache.Cache(asset); 352 m_Cache.Cache(asset);
329 return asset.ID; 353 return asset.ID;
330 } 354 }
331 355
332 string id = string.Empty; 356 string id;
333 if (IsHG(asset.ID)) 357 if (IsHG(asset.ID))
334 { 358 {
335 if (m_AssetPerms.AllowedExport(asset.Type)) 359 if (m_AssetPerms.AllowedExport(asset.Type))
@@ -340,18 +364,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
340 else 364 else
341 id = m_GridService.Store(asset); 365 id = m_GridService.Store(asset);
342 366
343 if (id != String.Empty) 367 if (String.IsNullOrEmpty(id))
344 { 368 return string.Empty;
345 // Placing this here, so that this work with old asset servers that don't send any reply back 369
346 // SynchronousRestObjectRequester returns somethins that is not an empty string 370 asset.ID = id;
347 if (id != null)
348 asset.ID = id;
349 371
350 if (m_Cache != null) 372 if (m_Cache != null)
351 m_Cache.Cache(asset); 373 m_Cache.Cache(asset);
352 }
353 return id;
354 374
375 return id;
355 } 376 }
356 377
357 public bool UpdateContent(string id, byte[] data) 378 public bool UpdateContent(string id, byte[] data)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
index 480cd69..5f34450 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs
@@ -236,7 +236,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
236 236
237 if (asset != null) 237 if (asset != null)
238 { 238 {
239 Util.FireAndForget(delegate { handler(id, sender, asset); }); 239 Util.FireAndForget(
240 o => handler(id, sender, asset), null, "LocalAssetServiceConnector.GotFromCacheCallback");
240 return true; 241 return true;
241 } 242 }
242 } 243 }
@@ -249,16 +250,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
249// if (null == a) 250// if (null == a)
250// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); 251// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id);
251 252
252 Util.FireAndForget(delegate { handler(assetID, s, a); }); 253 Util.FireAndForget(
254 o => handler(assetID, s, a), null, "LocalAssetServiceConnector.GotFromServiceCallback");
253 }); 255 });
254 } 256 }
255 257
258 public bool[] AssetsExist(string[] ids)
259 {
260 return m_AssetService.AssetsExist(ids);
261 }
262
256 public string Store(AssetBase asset) 263 public string Store(AssetBase asset)
257 { 264 {
258 if (m_Cache != null) 265 if (m_Cache != null)
259 m_Cache.Cache(asset); 266 m_Cache.Cache(asset);
260 267
261 if (asset.Temporary || asset.Local) 268 if (asset.Local)
262 { 269 {
263// m_log.DebugFormat( 270// m_log.DebugFormat(
264// "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}", 271// "[LOCAL ASSET SERVICE CONNECTOR]: Returning asset {0} {1} without querying database since status Temporary = {2}, Local = {3}",
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs
index 1982473..4f75191 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/Tests/AssetConnectorTests.cs
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common;
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests
43{ 43{
44 [TestFixture] 44 [TestFixture]
45 public class AssetConnectorsTests : OpenSimTestCase 45 public class AssetConnectorTests : OpenSimTestCase
46 { 46 {
47 [Test] 47 [Test]
48 public void TestAddAsset() 48 public void TestAddAsset()
@@ -77,7 +77,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests
77 // TODO: Add cache and check that this does receive a copy of the asset 77 // TODO: Add cache and check that this does receive a copy of the asset
78 } 78 }
79 79
80 [Test]
81 public void TestAddTemporaryAsset() 80 public void TestAddTemporaryAsset()
82 { 81 {
83 TestHelpers.InMethod(); 82 TestHelpers.InMethod();
@@ -93,8 +92,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests
93 LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); 92 LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();
94 lasc.Initialise(config); 93 lasc.Initialise(config);
95 94
95 // If it is remote, it should be stored
96 AssetBase a2 = AssetHelpers.CreateNotecardAsset();
97 a2.Local = false;
98 a2.Temporary = true;
99
100 lasc.Store(a2);
101
102 AssetBase retreivedA2 = lasc.Get(a2.ID);
103 Assert.That(retreivedA2.ID, Is.EqualTo(a2.ID));
104 Assert.That(retreivedA2.Metadata.ID, Is.EqualTo(a2.Metadata.ID));
105 Assert.That(retreivedA2.Data.Length, Is.EqualTo(a2.Data.Length));
106
107 AssetMetadata retrievedA2Metadata = lasc.GetMetadata(a2.ID);
108 Assert.That(retrievedA2Metadata.ID, Is.EqualTo(a2.ID));
109
110 byte[] retrievedA2Data = lasc.GetData(a2.ID);
111 Assert.That(retrievedA2Data.Length, Is.EqualTo(a2.Data.Length));
112
113 // TODO: Add cache and check that this does receive a copy of the asset
114 }
115
116 [Test]
117 public void TestAddLocalAsset()
118 {
119 TestHelpers.InMethod();
120// TestHelpers.EnableLogging();
121
122 IConfigSource config = new IniConfigSource();
123 config.AddConfig("Modules");
124 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
125 config.AddConfig("AssetService");
126 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
127 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
128
129 LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();
130 lasc.Initialise(config);
131
96 AssetBase a1 = AssetHelpers.CreateNotecardAsset(); 132 AssetBase a1 = AssetHelpers.CreateNotecardAsset();
97 a1.Temporary = true; 133 a1.Local = true;
98 134
99 lasc.Store(a1); 135 lasc.Store(a1);
100 136
@@ -106,7 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests
106 } 142 }
107 143
108 [Test] 144 [Test]
109 public void TestAddLocalAsset() 145 public void TestAddTemporaryLocalAsset()
110 { 146 {
111 TestHelpers.InMethod(); 147 TestHelpers.InMethod();
112// TestHelpers.EnableLogging(); 148// TestHelpers.EnableLogging();
@@ -121,8 +157,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.Tests
121 LocalAssetServicesConnector lasc = new LocalAssetServicesConnector(); 157 LocalAssetServicesConnector lasc = new LocalAssetServicesConnector();
122 lasc.Initialise(config); 158 lasc.Initialise(config);
123 159
160 // If it is local, it should not be stored
124 AssetBase a1 = AssetHelpers.CreateNotecardAsset(); 161 AssetBase a1 = AssetHelpers.CreateNotecardAsset();
125 a1.Local = true; 162 a1.Local = true;
163 a1.Temporary = true;
126 164
127 lasc.Store(a1); 165 lasc.Store(a1);
128 166
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
index 4470799..93dff1f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/AuthorizationService.cs
@@ -89,35 +89,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
89 public bool IsAuthorizedForRegion( 89 public bool IsAuthorizedForRegion(
90 string user, string firstName, string lastName, string regionID, out string message) 90 string user, string firstName, string lastName, string regionID, out string message)
91 { 91 {
92 message = "authorized";
93
94 // This should not happen 92 // This should not happen
95 if (m_Scene.RegionInfo.RegionID.ToString() != regionID) 93 if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
96 { 94 {
97 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}", 95 m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}",
98 m_Scene.RegionInfo.RegionID, regionID); 96 m_Scene.RegionInfo.RegionID, regionID);
99 return true; 97 message = string.Format("Region {0} received request to authorize for region {1}", m_Scene.RegionInfo.RegionID, regionID);
98 return false;
100 } 99 }
101 100
102 if (m_accessValue == AccessFlags.None) 101 if (m_accessValue == AccessFlags.None)
102 {
103 message = "Authorized";
103 return true; 104 return true;
105 }
104 106
105 UUID userID = new UUID(user); 107 UUID userID = new UUID(user);
106 bool authorized = true; 108
107 if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners) 109 if ((m_accessValue & AccessFlags.DisallowForeigners) != 0)
108 { 110 {
109 authorized = m_UserManagement.IsLocalGridUser(userID); 111 if (!m_UserManagement.IsLocalGridUser(userID))
110 if (!authorized) 112 {
111 message = "no foreigner users allowed in this region"; 113 message = "No foreign users allowed in this region";
114 return false;
115 }
112 } 116 }
113 if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents) 117
118 if ((m_accessValue & AccessFlags.DisallowResidents) != 0)
114 { 119 {
115 authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID); 120 if (!(m_Scene.Permissions.IsGod(userID) || m_Scene.Permissions.IsAdministrator(userID)))
116 if (!authorized) 121 {
117 message = "only Admins and Managers allowed in this region"; 122 message = "Only Admins and Managers allowed in this region";
123 return false;
124 }
118 } 125 }
119 126
120 return authorized; 127 message = "Authorized";
128 return true;
121 } 129 }
122 130
123 } 131 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index c0c2ca7..1f782f5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
48 private static readonly ILog m_log = 48 private static readonly ILog m_log =
49 LogManager.GetLogger( 49 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType); 50 MethodBase.GetCurrentMethod().DeclaringType);
51 private static string LogHeader = "[LOCAL GRID SERVICE CONNECTOR]";
51 52
52 private IGridService m_GridService; 53 private IGridService m_GridService;
53 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); 54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
@@ -56,11 +57,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
56 57
57 public LocalGridServicesConnector() 58 public LocalGridServicesConnector()
58 { 59 {
60 m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader);
59 } 61 }
60 62
61 public LocalGridServicesConnector(IConfigSource source) 63 public LocalGridServicesConnector(IConfigSource source)
62 { 64 {
63 m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly."); 65 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader);
64 InitialiseService(source); 66 InitialiseService(source);
65 } 67 }
66 68
@@ -92,15 +94,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
92 94
93 private void InitialiseService(IConfigSource source) 95 private void InitialiseService(IConfigSource source)
94 { 96 {
95 IConfig assetConfig = source.Configs["GridService"]; 97 IConfig config = source.Configs["GridService"];
96 if (assetConfig == null) 98 if (config == null)
97 { 99 {
98 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); 100 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
99 return; 101 return;
100 } 102 }
101 103
102 string serviceDll = assetConfig.GetString("LocalServiceModule", 104 string serviceDll = config.GetString("LocalServiceModule", String.Empty);
103 String.Empty);
104 105
105 if (serviceDll == String.Empty) 106 if (serviceDll == String.Empty)
106 { 107 {
@@ -142,10 +143,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
142 143
143 scene.RegisterModuleInterface<IGridService>(this); 144 scene.RegisterModuleInterface<IGridService>(this);
144 145
145 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) 146 lock (m_LocalCache)
146 m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); 147 {
147 else 148 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
148 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); 149 m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
150 else
151 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
152 }
149 } 153 }
150 154
151 public void RemoveRegion(Scene scene) 155 public void RemoveRegion(Scene scene)
@@ -153,8 +157,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
153 if (!m_Enabled) 157 if (!m_Enabled)
154 return; 158 return;
155 159
156 m_LocalCache[scene.RegionInfo.RegionID].Clear(); 160 lock (m_LocalCache)
157 m_LocalCache.Remove(scene.RegionInfo.RegionID); 161 {
162 m_LocalCache[scene.RegionInfo.RegionID].Clear();
163 m_LocalCache.Remove(scene.RegionInfo.RegionID);
164 }
158 } 165 }
159 166
160 public void RegionLoaded(Scene scene) 167 public void RegionLoaded(Scene scene)
@@ -185,23 +192,59 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
185 return m_GridService.GetRegionByUUID(scopeID, regionID); 192 return m_GridService.GetRegionByUUID(scopeID, regionID);
186 } 193 }
187 194
195 // Get a region given its base coordinates.
196 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
197 // be the base coordinate of the region.
188 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 198 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
189 { 199 {
190 GridRegion region = null; 200 GridRegion region = null;
201 uint regionX = Util.WorldToRegionLoc((uint)x);
202 uint regionY = Util.WorldToRegionLoc((uint)y);
203
204 // Sanity check
205 if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y))
206 {
207 m_log.WarnFormat("{0} GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{1},{2}>, Should Be=<{3},{4}>",
208 LogHeader, x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY));
209 }
191 210
192 // First see if it's a neighbour, even if it isn't on this sim. 211 // First see if it's a neighbour, even if it isn't on this sim.
193 // Neighbour data is cached in memory, so this is fast 212 // Neighbour data is cached in memory, so this is fast
194 foreach (RegionCache rcache in m_LocalCache.Values) 213
214 lock (m_LocalCache)
195 { 215 {
196 region = rcache.GetRegionByPosition(x, y); 216 foreach (RegionCache rcache in m_LocalCache.Values)
197 if (region != null)
198 { 217 {
199 return region; 218 region = rcache.GetRegionByPosition(x, y);
219 if (region != null)
220 {
221 m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>",
222 LogHeader, region.RegionName, rcache.RegionName,
223 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
224 break;
225 }
200 } 226 }
201 } 227 }
202 228
203 // Then try on this sim (may be a lookup in DB if this is using MySql). 229 // Then try on this sim (may be a lookup in DB if this is using MySql).
204 return m_GridService.GetRegionByPosition(scopeID, x, y); 230 if (region == null)
231 {
232 region = m_GridService.GetRegionByPosition(scopeID, x, y);
233
234 if (region == null)
235 {
236 m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
237 LogHeader, regionX, regionY);
238 }
239 else
240 {
241 m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
242 LogHeader, region.RegionName,
243 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
244 }
245 }
246
247 return region;
205 } 248 }
206 249
207 public GridRegion GetRegionByName(UUID scopeID, string regionName) 250 public GridRegion GetRegionByName(UUID scopeID, string regionName)
@@ -224,6 +267,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
224 return m_GridService.GetDefaultRegions(scopeID); 267 return m_GridService.GetDefaultRegions(scopeID);
225 } 268 }
226 269
270 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
271 {
272 return m_GridService.GetDefaultHypergridRegions(scopeID);
273 }
274
227 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 275 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
228 { 276 {
229 return m_GridService.GetFallbackRegions(scopeID, x, y); 277 return m_GridService.GetFallbackRegions(scopeID, x, y);
@@ -239,21 +287,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
239 return m_GridService.GetRegionFlags(scopeID, regionID); 287 return m_GridService.GetRegionFlags(scopeID, regionID);
240 } 288 }
241 289
290 public Dictionary<string, object> GetExtraFeatures()
291 {
292 return m_GridService.GetExtraFeatures();
293 }
294
242 #endregion 295 #endregion
243 296
244 public void HandleShowNeighboursCommand(string module, string[] cmdparams) 297 public void HandleShowNeighboursCommand(string module, string[] cmdparams)
245 { 298 {
246 System.Text.StringBuilder caps = new System.Text.StringBuilder(); 299 System.Text.StringBuilder caps = new System.Text.StringBuilder();
247 300
248 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) 301 lock (m_LocalCache)
249 { 302 {
250 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); 303 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
251 List<GridRegion> regions = kvp.Value.GetNeighbours(); 304 {
252 foreach (GridRegion r in regions) 305 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
253 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); 306 List<GridRegion> regions = kvp.Value.GetNeighbours();
307 foreach (GridRegion r in regions)
308 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
309 }
254 } 310 }
255 311
256 MainConsole.Instance.Output(caps.ToString()); 312 MainConsole.Instance.Output(caps.ToString());
257 } 313 }
258 } 314 }
259} \ No newline at end of file 315}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
index 9172536..ae76288 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
66 return; 66 return;
67 67
68 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", 68 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
69 m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX / Constants.RegionSize, otherRegion.RegionLocY / Constants.RegionSize); 69 m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY));
70 70
71 m_neighbours[otherRegion.RegionHandle] = otherRegion; 71 m_neighbours[otherRegion.RegionHandle] = otherRegion;
72 } 72 }
@@ -82,11 +82,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
82 return new List<GridRegion>(m_neighbours.Values); 82 return new List<GridRegion>(m_neighbours.Values);
83 } 83 }
84 84
85 // Get a region given its base coordinates (in meters).
86 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
87 // be the base coordinate of the region.
88 // The snapping is technically unnecessary but is harmless because regions are always
89 // multiples of the legacy region size (256).
85 public GridRegion GetRegionByPosition(int x, int y) 90 public GridRegion GetRegionByPosition(int x, int y)
86 { 91 {
87 uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; 92 uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
88 uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; 93 uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize;
89 ulong handle = Utils.UIntsToLong(xsnap, ysnap); 94 ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap);
90 95
91 if (m_neighbours.ContainsKey(handle)) 96 if (m_neighbours.ContainsKey(handle))
92 return m_neighbours[handle]; 97 return m_neighbours[handle];
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index b2646ba..85073fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -28,6 +28,7 @@
28using log4net; 28using log4net;
29using Mono.Addins; 29using Mono.Addins;
30using System; 30using System;
31using System.Collections;
31using System.Collections.Generic; 32using System.Collections.Generic;
32using System.Reflection; 33using System.Reflection;
33using Nini.Config; 34using Nini.Config;
@@ -186,18 +187,41 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
186 return rinfo; 187 return rinfo;
187 } 188 }
188 189
190 // Get a region given its base world coordinates (in meters).
191 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
192 // be the base coordinate of the region.
193 // The coordinates are world coords (meters), NOT region units.
189 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 194 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
190 { 195 {
196 ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
197 uint regionX = Util.WorldToRegionLoc((uint)x);
198 uint regionY = Util.WorldToRegionLoc((uint)y);
199
200 // Sanity check
201 if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y))
202 {
203 m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>",
204 x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY));
205 }
206
191 bool inCache = false; 207 bool inCache = false;
192 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache); 208 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
193 if (inCache) 209 if (inCache)
210 {
211 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}",
212 // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
194 return rinfo; 213 return rinfo;
214 }
195 215
196 rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); 216 rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
197 if (rinfo == null) 217 if (rinfo == null)
198 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); 218 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
199 219
200 m_RegionInfoCache.Cache(rinfo); 220 m_RegionInfoCache.Cache(rinfo);
221
222 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}",
223 // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle);
224
201 return rinfo; 225 return rinfo;
202 } 226 }
203 227
@@ -277,6 +301,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
277 return rinfo; 301 return rinfo;
278 } 302 }
279 303
304 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
305 {
306 List<GridRegion> rinfo = m_LocalGridService.GetDefaultHypergridRegions(scopeID);
307 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultHypergridRegions {0} found {1} regions", name, rinfo.Count);
308 List<GridRegion> grinfo = m_RemoteGridService.GetDefaultHypergridRegions(scopeID);
309
310 if (grinfo != null)
311 {
312 //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultHypergridRegions {0} found {1} regions", name, grinfo.Count);
313 foreach (GridRegion r in grinfo)
314 {
315 m_RegionInfoCache.Cache(r);
316 if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
317 rinfo.Add(r);
318 }
319 }
320
321 return rinfo;
322 }
323
280 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 324 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
281 { 325 {
282 List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y); 326 List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y);
@@ -325,6 +369,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
325 369
326 return flags; 370 return flags;
327 } 371 }
372
373 public Dictionary<string, object> GetExtraFeatures()
374 {
375 Dictionary<string, object> extraFeatures;
376 extraFeatures = m_LocalGridService.GetExtraFeatures();
377
378 if (extraFeatures.Count == 0)
379 extraFeatures = m_RemoteGridService.GetExtraFeatures();
380
381 return extraFeatures;
382 }
328 #endregion 383 #endregion
329 } 384 }
330} 385}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index 4338133..25ae689 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -34,6 +34,7 @@ using log4net.Config;
34using Nini.Config; 34using Nini.Config;
35using NUnit.Framework; 35using NUnit.Framework;
36using OpenMetaverse; 36using OpenMetaverse;
37
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; 39using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -141,7 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
141 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); 142 Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
142 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); 143 Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
143 144
144 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); 145 result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
145 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); 146 Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
146 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); 147 Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
147 148
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
index 221f815..2238c90 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
@@ -67,10 +67,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
67 { 67 {
68 if (sp.PresenceType != PresenceType.Npc) 68 if (sp.PresenceType != PresenceType.Npc)
69 { 69 {
70 string userid = sp.Scene.UserManagementModule.GetUserUUI(sp.UUID); 70 string userid;
71 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName); 71 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName);
72 m_GridUserService.SetLastPosition( 72 if (sp.Scene.UserManagementModule.GetUserUUI(sp.UUID, out userid))
73 userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 73 {
74 /* we only setposition on known agents that have a valid lookup */
75 m_GridUserService.SetLastPosition(
76 userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
77 }
74 } 78 }
75 } 79 }
76 80
@@ -81,20 +85,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
81 85
82 public void OnConnectionClose(IClientAPI client) 86 public void OnConnectionClose(IClientAPI client)
83 { 87 {
88 if (client == null)
89 return;
90 if (client.SceneAgent == null)
91 return;
92
84 if (client.SceneAgent.IsChildAgent) 93 if (client.SceneAgent.IsChildAgent)
85 return; 94 return;
86 95
87 string userId = client.AgentId.ToString(); 96 string userId;
97 /* without scene we cannot logout correctly at all since we do not know how to send the loggedout message then */
88 if (client.Scene is Scene) 98 if (client.Scene is Scene)
89 { 99 {
90 Scene s = (Scene)client.Scene; 100 Scene s = (Scene)client.Scene;
91 userId = s.UserManagementModule.GetUserUUI(client.AgentId); 101 userId = s.UserManagementModule.GetUserUUI(client.AgentId);
102 if(s.UserManagementModule.GetUserUUI(client.AgentId, out userId))
103 {
104 m_GridUserService.LoggedOut(
105 userId, client.SessionId, client.Scene.RegionInfo.RegionID,
106 client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat);
107 }
92 } 108 }
93 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", userId, client.Scene.RegionInfo.RegionName);
94 109
95 m_GridUserService.LoggedOut(
96 userId, client.SessionId, client.Scene.RegionInfo.RegionID,
97 client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat);
98 } 110 }
99 } 111 }
100} 112}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index e474ef6..48f228a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -62,6 +62,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
62 62
63 private InventoryCache m_Cache = new InventoryCache(); 63 private InventoryCache m_Cache = new InventoryCache();
64 64
65 /// <summary>
66 /// Used to serialize inventory requests.
67 /// </summary>
68 private object m_Lock = new object();
69
65 protected IUserManagement m_UserManagement; 70 protected IUserManagement m_UserManagement;
66 protected IUserManagement UserManagementModule 71 protected IUserManagement UserManagementModule
67 { 72 {
@@ -233,13 +238,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
233 if (sp != null) 238 if (sp != null)
234 { 239 {
235 AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 240 AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
241 if (aCircuit == null)
242 return;
243 if (aCircuit.ServiceURLs == null)
244 return;
245
236 if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) 246 if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI"))
237 { 247 {
238 inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); 248 inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString();
239 if (inventoryURL != null && inventoryURL != string.Empty) 249 if (inventoryURL != null && inventoryURL != string.Empty)
240 { 250 {
241 inventoryURL = inventoryURL.Trim(new char[] { '/' }); 251 inventoryURL = inventoryURL.Trim(new char[] { '/' });
242 m_InventoryURLs.Add(userID, inventoryURL); 252 m_InventoryURLs[userID] = inventoryURL;
243 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL); 253 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Added {0} to the cache of inventory URLs", inventoryURL);
244 return; 254 return;
245 } 255 }
@@ -254,7 +264,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
254 if (sp == null) 264 if (sp == null)
255 { 265 {
256 inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI"); 266 inventoryURL = UserManagementModule.GetUserServerURL(userID, "InventoryServerURI");
257 if (inventoryURL != null && inventoryURL != string.Empty) 267 if (!string.IsNullOrEmpty(inventoryURL))
258 { 268 {
259 inventoryURL = inventoryURL.Trim(new char[] { '/' }); 269 inventoryURL = inventoryURL.Trim(new char[] { '/' });
260 m_InventoryURLs.Add(userID, inventoryURL); 270 m_InventoryURLs.Add(userID, inventoryURL);
@@ -296,7 +306,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
296 306
297 public bool CreateUserInventory(UUID userID) 307 public bool CreateUserInventory(UUID userID)
298 { 308 {
299 return m_LocalGridInventoryService.CreateUserInventory(userID); 309 lock (m_Lock)
310 return m_LocalGridInventoryService.CreateUserInventory(userID);
300 } 311 }
301 312
302 public List<InventoryFolderBase> GetInventorySkeleton(UUID userID) 313 public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
@@ -304,36 +315,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
304 string invURL = GetInventoryServiceURL(userID); 315 string invURL = GetInventoryServiceURL(userID);
305 316
306 if (invURL == null) // not there, forward to local inventory connector to resolve 317 if (invURL == null) // not there, forward to local inventory connector to resolve
307 return m_LocalGridInventoryService.GetInventorySkeleton(userID); 318 lock (m_Lock)
319 return m_LocalGridInventoryService.GetInventorySkeleton(userID);
308 320
309 IInventoryService connector = GetConnector(invURL); 321 IInventoryService connector = GetConnector(invURL);
310 322
311 return connector.GetInventorySkeleton(userID); 323 return connector.GetInventorySkeleton(userID);
312 } 324 }
313 325
314 public InventoryCollection GetUserInventory(UUID userID)
315 {
316 string invURL = GetInventoryServiceURL(userID);
317 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL);
318
319 if (invURL == null) // not there, forward to local inventory connector to resolve
320 return m_LocalGridInventoryService.GetUserInventory(userID);
321
322 InventoryCollection c = m_Cache.GetUserInventory(userID);
323 if (c != null)
324 return c;
325
326 IInventoryService connector = GetConnector(invURL);
327 c = connector.GetUserInventory(userID);
328
329 m_Cache.Cache(userID, c);
330 return c;
331 }
332
333 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
334 {
335 }
336
337 public InventoryFolderBase GetRootFolder(UUID userID) 326 public InventoryFolderBase GetRootFolder(UUID userID)
338 { 327 {
339 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID); 328 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetRootFolder for {0}", userID);
@@ -344,7 +333,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
344 string invURL = GetInventoryServiceURL(userID); 333 string invURL = GetInventoryServiceURL(userID);
345 334
346 if (invURL == null) // not there, forward to local inventory connector to resolve 335 if (invURL == null) // not there, forward to local inventory connector to resolve
347 return m_LocalGridInventoryService.GetRootFolder(userID); 336 lock (m_Lock)
337 return m_LocalGridInventoryService.GetRootFolder(userID);
348 338
349 IInventoryService connector = GetConnector(invURL); 339 IInventoryService connector = GetConnector(invURL);
350 340
@@ -355,7 +345,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
355 return root; 345 return root;
356 } 346 }
357 347
358 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 348 public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
359 { 349 {
360 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type); 350 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetFolderForType {0} type {1}", userID, type);
361 InventoryFolderBase f = m_Cache.GetFolderForType(userID, type); 351 InventoryFolderBase f = m_Cache.GetFolderForType(userID, type);
@@ -365,7 +355,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
365 string invURL = GetInventoryServiceURL(userID); 355 string invURL = GetInventoryServiceURL(userID);
366 356
367 if (invURL == null) // not there, forward to local inventory connector to resolve 357 if (invURL == null) // not there, forward to local inventory connector to resolve
368 return m_LocalGridInventoryService.GetFolderForType(userID, type); 358 lock (m_Lock)
359 return m_LocalGridInventoryService.GetFolderForType(userID, type);
369 360
370 IInventoryService connector = GetConnector(invURL); 361 IInventoryService connector = GetConnector(invURL);
371 362
@@ -383,7 +374,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
383 string invURL = GetInventoryServiceURL(userID); 374 string invURL = GetInventoryServiceURL(userID);
384 375
385 if (invURL == null) // not there, forward to local inventory connector to resolve 376 if (invURL == null) // not there, forward to local inventory connector to resolve
386 return m_LocalGridInventoryService.GetFolderContent(userID, folderID); 377 lock (m_Lock)
378 return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
387 379
388 InventoryCollection c = m_Cache.GetFolderContent(userID, folderID); 380 InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
389 if (c != null) 381 if (c != null)
@@ -393,8 +385,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
393 } 385 }
394 386
395 IInventoryService connector = GetConnector(invURL); 387 IInventoryService connector = GetConnector(invURL);
388
396 return connector.GetFolderContent(userID, folderID); 389 return connector.GetFolderContent(userID, folderID);
390 }
397 391
392 public InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs)
393 {
394 string invURL = GetInventoryServiceURL(userID);
395
396 if (invURL == null) // not there, forward to local inventory connector to resolve
397 lock (m_Lock)
398 return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs);
399
400 else
401 {
402 InventoryCollection[] coll = new InventoryCollection[folderIDs.Length];
403 int i = 0;
404 foreach (UUID fid in folderIDs)
405 coll[i++] = GetFolderContent(userID, fid);
406
407 return coll;
408 }
398 } 409 }
399 410
400 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 411 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
@@ -404,7 +415,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
404 string invURL = GetInventoryServiceURL(userID); 415 string invURL = GetInventoryServiceURL(userID);
405 416
406 if (invURL == null) // not there, forward to local inventory connector to resolve 417 if (invURL == null) // not there, forward to local inventory connector to resolve
407 return m_LocalGridInventoryService.GetFolderItems(userID, folderID); 418 lock (m_Lock)
419 return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
408 420
409 List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID); 421 List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
410 if (items != null) 422 if (items != null)
@@ -414,8 +426,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
414 } 426 }
415 427
416 IInventoryService connector = GetConnector(invURL); 428 IInventoryService connector = GetConnector(invURL);
417 return connector.GetFolderItems(userID, folderID);
418 429
430 return connector.GetFolderItems(userID, folderID);
419 } 431 }
420 432
421 public bool AddFolder(InventoryFolderBase folder) 433 public bool AddFolder(InventoryFolderBase folder)
@@ -428,7 +440,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
428 string invURL = GetInventoryServiceURL(folder.Owner); 440 string invURL = GetInventoryServiceURL(folder.Owner);
429 441
430 if (invURL == null) // not there, forward to local inventory connector to resolve 442 if (invURL == null) // not there, forward to local inventory connector to resolve
431 return m_LocalGridInventoryService.AddFolder(folder); 443 lock (m_Lock)
444 return m_LocalGridInventoryService.AddFolder(folder);
432 445
433 IInventoryService connector = GetConnector(invURL); 446 IInventoryService connector = GetConnector(invURL);
434 447
@@ -445,7 +458,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
445 string invURL = GetInventoryServiceURL(folder.Owner); 458 string invURL = GetInventoryServiceURL(folder.Owner);
446 459
447 if (invURL == null) // not there, forward to local inventory connector to resolve 460 if (invURL == null) // not there, forward to local inventory connector to resolve
448 return m_LocalGridInventoryService.UpdateFolder(folder); 461 lock (m_Lock)
462 return m_LocalGridInventoryService.UpdateFolder(folder);
449 463
450 IInventoryService connector = GetConnector(invURL); 464 IInventoryService connector = GetConnector(invURL);
451 465
@@ -464,7 +478,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
464 string invURL = GetInventoryServiceURL(ownerID); 478 string invURL = GetInventoryServiceURL(ownerID);
465 479
466 if (invURL == null) // not there, forward to local inventory connector to resolve 480 if (invURL == null) // not there, forward to local inventory connector to resolve
467 return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs); 481 lock (m_Lock)
482 return m_LocalGridInventoryService.DeleteFolders(ownerID, folderIDs);
468 483
469 IInventoryService connector = GetConnector(invURL); 484 IInventoryService connector = GetConnector(invURL);
470 485
@@ -481,7 +496,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
481 string invURL = GetInventoryServiceURL(folder.Owner); 496 string invURL = GetInventoryServiceURL(folder.Owner);
482 497
483 if (invURL == null) // not there, forward to local inventory connector to resolve 498 if (invURL == null) // not there, forward to local inventory connector to resolve
484 return m_LocalGridInventoryService.MoveFolder(folder); 499 lock (m_Lock)
500 return m_LocalGridInventoryService.MoveFolder(folder);
485 501
486 IInventoryService connector = GetConnector(invURL); 502 IInventoryService connector = GetConnector(invURL);
487 503
@@ -498,7 +514,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
498 string invURL = GetInventoryServiceURL(folder.Owner); 514 string invURL = GetInventoryServiceURL(folder.Owner);
499 515
500 if (invURL == null) // not there, forward to local inventory connector to resolve 516 if (invURL == null) // not there, forward to local inventory connector to resolve
501 return m_LocalGridInventoryService.PurgeFolder(folder); 517 lock (m_Lock)
518 return m_LocalGridInventoryService.PurgeFolder(folder);
502 519
503 IInventoryService connector = GetConnector(invURL); 520 IInventoryService connector = GetConnector(invURL);
504 521
@@ -515,7 +532,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
515 string invURL = GetInventoryServiceURL(item.Owner); 532 string invURL = GetInventoryServiceURL(item.Owner);
516 533
517 if (invURL == null) // not there, forward to local inventory connector to resolve 534 if (invURL == null) // not there, forward to local inventory connector to resolve
518 return m_LocalGridInventoryService.AddItem(item); 535 lock (m_Lock)
536 return m_LocalGridInventoryService.AddItem(item);
519 537
520 IInventoryService connector = GetConnector(invURL); 538 IInventoryService connector = GetConnector(invURL);
521 539
@@ -532,7 +550,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
532 string invURL = GetInventoryServiceURL(item.Owner); 550 string invURL = GetInventoryServiceURL(item.Owner);
533 551
534 if (invURL == null) // not there, forward to local inventory connector to resolve 552 if (invURL == null) // not there, forward to local inventory connector to resolve
535 return m_LocalGridInventoryService.UpdateItem(item); 553 lock (m_Lock)
554 return m_LocalGridInventoryService.UpdateItem(item);
536 555
537 IInventoryService connector = GetConnector(invURL); 556 IInventoryService connector = GetConnector(invURL);
538 557
@@ -551,7 +570,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
551 string invURL = GetInventoryServiceURL(ownerID); 570 string invURL = GetInventoryServiceURL(ownerID);
552 571
553 if (invURL == null) // not there, forward to local inventory connector to resolve 572 if (invURL == null) // not there, forward to local inventory connector to resolve
554 return m_LocalGridInventoryService.MoveItems(ownerID, items); 573 lock (m_Lock)
574 return m_LocalGridInventoryService.MoveItems(ownerID, items);
555 575
556 IInventoryService connector = GetConnector(invURL); 576 IInventoryService connector = GetConnector(invURL);
557 577
@@ -570,7 +590,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
570 string invURL = GetInventoryServiceURL(ownerID); 590 string invURL = GetInventoryServiceURL(ownerID);
571 591
572 if (invURL == null) // not there, forward to local inventory connector to resolve 592 if (invURL == null) // not there, forward to local inventory connector to resolve
573 return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs); 593 lock (m_Lock)
594 return m_LocalGridInventoryService.DeleteItems(ownerID, itemIDs);
574 595
575 IInventoryService connector = GetConnector(invURL); 596 IInventoryService connector = GetConnector(invURL);
576 597
@@ -586,13 +607,31 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
586 string invURL = GetInventoryServiceURL(item.Owner); 607 string invURL = GetInventoryServiceURL(item.Owner);
587 608
588 if (invURL == null) // not there, forward to local inventory connector to resolve 609 if (invURL == null) // not there, forward to local inventory connector to resolve
589 return m_LocalGridInventoryService.GetItem(item); 610 lock (m_Lock)
611 return m_LocalGridInventoryService.GetItem(item);
590 612
591 IInventoryService connector = GetConnector(invURL); 613 IInventoryService connector = GetConnector(invURL);
592 614
593 return connector.GetItem(item); 615 return connector.GetItem(item);
594 } 616 }
595 617
618 public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs)
619 {
620 if (itemIDs == null)
621 return new InventoryItemBase[0];
622 //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID);
623
624 string invURL = GetInventoryServiceURL(userID);
625
626 if (invURL == null) // not there, forward to local inventory connector to resolve
627 lock (m_Lock)
628 return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs);
629
630 IInventoryService connector = GetConnector(invURL);
631
632 return connector.GetMultipleItems(userID, itemIDs);
633 }
634
596 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 635 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
597 { 636 {
598 if (folder == null) 637 if (folder == null)
@@ -603,7 +642,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
603 string invURL = GetInventoryServiceURL(folder.Owner); 642 string invURL = GetInventoryServiceURL(folder.Owner);
604 643
605 if (invURL == null) // not there, forward to local inventory connector to resolve 644 if (invURL == null) // not there, forward to local inventory connector to resolve
606 return m_LocalGridInventoryService.GetFolder(folder); 645 lock (m_Lock)
646 return m_LocalGridInventoryService.GetFolder(folder);
607 647
608 IInventoryService connector = GetConnector(invURL); 648 IInventoryService connector = GetConnector(invURL);
609 649
@@ -627,7 +667,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
627 string invURL = GetInventoryServiceURL(userID); 667 string invURL = GetInventoryServiceURL(userID);
628 668
629 if (invURL == null) // not there, forward to local inventory connector to resolve 669 if (invURL == null) // not there, forward to local inventory connector to resolve
630 return m_LocalGridInventoryService.GetAssetPermissions(userID, assetID); 670 lock (m_Lock)
671 return m_LocalGridInventoryService.GetAssetPermissions(userID, assetID);
631 672
632 IInventoryService connector = GetConnector(invURL); 673 IInventoryService connector = GetConnector(invURL);
633 674
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
index 1e434b9..3195e6b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -1,23 +1,52 @@
1using System; 1/*
2using System.Collections.Generic; 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 */
3 27
28using System;
29using System.Collections.Generic;
30using System.Threading;
4using OpenSim.Framework; 31using OpenSim.Framework;
5using OpenMetaverse; 32using OpenMetaverse;
6 33
7namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 34namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
8{ 35{
36 /// <summary>
37 /// Cache root and system inventory folders to reduce number of potentially remote inventory calls and associated holdups.
38 /// </summary>
9 public class InventoryCache 39 public class InventoryCache
10 { 40 {
11 private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour 41 private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour
12 42
13 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); 43 private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
14 private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); 44 private static ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<FolderType, InventoryFolderBase>>();
15 private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>(); 45 private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>();
16 46
17 public void Cache(UUID userID, InventoryFolderBase root) 47 public void Cache(UUID userID, InventoryFolderBase root)
18 { 48 {
19 lock (m_RootFolders) 49 m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
20 m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS);
21 } 50 }
22 51
23 public InventoryFolderBase GetRootFolder(UUID userID) 52 public InventoryFolderBase GetRootFolder(UUID userID)
@@ -29,29 +58,37 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
29 return null; 58 return null;
30 } 59 }
31 60
32 public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) 61 public void Cache(UUID userID, FolderType type, InventoryFolderBase folder)
33 { 62 {
34 lock (m_FolderTypes) 63 Dictionary<FolderType, InventoryFolderBase> ff = null;
64 if (!m_FolderTypes.TryGetValue(userID, out ff))
65 {
66 ff = new Dictionary<FolderType, InventoryFolderBase>();
67 m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
68 }
69
70 // We need to lock here since two threads could potentially retrieve the same dictionary
71 // and try to add a folder for that type simultaneously. Dictionary<>.Add() is not described as thread-safe in the SDK
72 // even if the folders are identical.
73 lock (ff)
35 { 74 {
36 Dictionary<AssetType, InventoryFolderBase> ff = null;
37 if (!m_FolderTypes.TryGetValue(userID, out ff))
38 {
39 ff = new Dictionary<AssetType, InventoryFolderBase>();
40 m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS);
41 }
42 if (!ff.ContainsKey(type)) 75 if (!ff.ContainsKey(type))
43 ff.Add(type, folder); 76 ff.Add(type, folder);
44 } 77 }
45 } 78 }
46 79
47 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 80 public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
48 { 81 {
49 Dictionary<AssetType, InventoryFolderBase> ff = null; 82 Dictionary<FolderType, InventoryFolderBase> ff = null;
50 if (m_FolderTypes.TryGetValue(userID, out ff)) 83 if (m_FolderTypes.TryGetValue(userID, out ff))
51 { 84 {
52 InventoryFolderBase f = null; 85 InventoryFolderBase f = null;
53 if (ff.TryGetValue(type, out f)) 86
54 return f; 87 lock (ff)
88 {
89 if (ff.TryGetValue(type, out f))
90 return f;
91 }
55 } 92 }
56 93
57 return null; 94 return null;
@@ -59,16 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
59 96
60 public void Cache(UUID userID, InventoryCollection inv) 97 public void Cache(UUID userID, InventoryCollection inv)
61 { 98 {
62 lock (m_Inventories) 99 m_Inventories.AddOrUpdate(userID, inv, 120);
63 m_Inventories.AddOrUpdate(userID, inv, 120);
64 }
65
66 public InventoryCollection GetUserInventory(UUID userID)
67 {
68 InventoryCollection inv = null;
69 if (m_Inventories.TryGetValue(userID, out inv))
70 return inv;
71 return null;
72 } 100 }
73 101
74 public InventoryCollection GetFolderContent(UUID userID, UUID folderID) 102 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
@@ -78,7 +106,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
78 if (m_Inventories.TryGetValue(userID, out inv)) 106 if (m_Inventories.TryGetValue(userID, out inv))
79 { 107 {
80 c = new InventoryCollection(); 108 c = new InventoryCollection();
81 c.UserID = userID; 109 c.OwnerID = userID;
82 110
83 c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f) 111 c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
84 { 112 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index ec5751d..20d4e02 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -33,6 +33,7 @@ using System;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using System.Reflection; 34using System.Reflection;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Monitoring;
36using OpenSim.Data; 37using OpenSim.Data;
37using OpenSim.Server.Base; 38using OpenSim.Server.Base;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
@@ -164,22 +165,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
164 return m_InventoryService.GetInventorySkeleton(userId); 165 return m_InventoryService.GetInventorySkeleton(userId);
165 } 166 }
166 167
167 public InventoryCollection GetUserInventory(UUID id)
168 {
169 return m_InventoryService.GetUserInventory(id);
170 }
171
172 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
173 {
174 m_InventoryService.GetUserInventory(userID, callback);
175 }
176
177 public InventoryFolderBase GetRootFolder(UUID userID) 168 public InventoryFolderBase GetRootFolder(UUID userID)
178 { 169 {
179 return m_InventoryService.GetRootFolder(userID); 170 return m_InventoryService.GetRootFolder(userID);
180 } 171 }
181 172
182 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 173 public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
183 { 174 {
184 return m_InventoryService.GetFolderForType(userID, type); 175 return m_InventoryService.GetFolderForType(userID, type);
185 } 176 }
@@ -193,16 +184,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
193 // Protect ourselves against the caller subsequently modifying the items list 184 // Protect ourselves against the caller subsequently modifying the items list
194 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); 185 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
195 186
196 Util.FireAndForget(delegate 187 WorkManager.RunInThread(delegate
197 { 188 {
198 foreach (InventoryItemBase item in items) 189 foreach (InventoryItemBase item in items)
199 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); 190 if (!string.IsNullOrEmpty(item.CreatorData))
200 }); 191 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
192 }, null, string.Format("GetFolderContent (user {0}, folder {1})", userID, folderID));
201 } 193 }
202 194
203 return invCol; 195 return invCol;
204 } 196 }
205 197
198 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
199 {
200 InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
201 int i = 0;
202 foreach (UUID fid in folderIDs)
203 {
204 invColl[i++] = GetFolderContent(principalID, fid);
205 }
206
207 return invColl;
208
209 }
210
206 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 211 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
207 { 212 {
208 return m_InventoryService.GetFolderItems(userID, folderID); 213 return m_InventoryService.GetFolderItems(userID, folderID);
@@ -302,6 +307,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
302 return item; 307 return item;
303 } 308 }
304 309
310 public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs)
311 {
312 return m_InventoryService.GetMultipleItems(userID, itemIDs);
313 }
314
305 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 315 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
306 { 316 {
307 return m_InventoryService.GetFolder(folder); 317 return m_InventoryService.GetFolder(folder);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 2d3ba82..978b9d9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -172,21 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
172 return m_RemoteConnector.GetInventorySkeleton(userId); 172 return m_RemoteConnector.GetInventorySkeleton(userId);
173 } 173 }
174 174
175 public InventoryCollection GetUserInventory(UUID userID)
176 {
177 return m_RemoteConnector.GetUserInventory(userID);
178 }
179
180 public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
181 {
182 }
183
184 public InventoryFolderBase GetRootFolder(UUID userID) 175 public InventoryFolderBase GetRootFolder(UUID userID)
185 { 176 {
186 return m_RemoteConnector.GetRootFolder(userID); 177 return m_RemoteConnector.GetRootFolder(userID);
187 } 178 }
188 179
189 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) 180 public InventoryFolderBase GetFolderForType(UUID userID, FolderType type)
190 { 181 {
191 return m_RemoteConnector.GetFolderForType(userID, type); 182 return m_RemoteConnector.GetFolderForType(userID, type);
192 } 183 }
@@ -195,22 +186,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
195 { 186 {
196 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); 187 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
197 188
198 if (invCol != null && UserManager != null) 189 // Commenting this for now, because it's causing more grief than good
199 { 190 //if (invCol != null && UserManager != null)
200 // Protect ourselves against the caller subsequently modifying the items list 191 //{
201 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); 192 // // Protect ourselves against the caller subsequently modifying the items list
202 193 // List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
203 if (items != null && items.Count > 0) 194
204 Util.FireAndForget(delegate 195 // if (items != null && items.Count > 0)
205 { 196 // //Util.FireAndForget(delegate
206 foreach (InventoryItemBase item in items) 197 // //{
207 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); 198 // foreach (InventoryItemBase item in items)
208 }); 199 // if (!string.IsNullOrEmpty(item.CreatorData))
209 } 200 // UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
201 // //});
202 //}
210 203
211 return invCol; 204 return invCol;
212 } 205 }
213 206
207 public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
208 {
209 return m_RemoteConnector.GetMultipleFoldersContent(principalID, folderIDs);
210 }
211
214 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 212 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
215 { 213 {
216 return m_RemoteConnector.GetFolderItems(userID, folderID); 214 return m_RemoteConnector.GetFolderItems(userID, folderID);
@@ -305,6 +303,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
305 return m_RemoteConnector.GetItem(item); 303 return m_RemoteConnector.GetItem(item);
306 } 304 }
307 305
306 public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs)
307 {
308 if (itemIDs == null)
309 return new InventoryItemBase[0];
310
311 return m_RemoteConnector.GetMultipleItems(userID, itemIDs);
312 }
313
308 public InventoryFolderBase GetFolder(InventoryFolderBase folder) 314 public InventoryFolderBase GetFolder(InventoryFolderBase folder)
309 { 315 {
310 //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID); 316 //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index a839086..08d6bdd 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -53,10 +53,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
53 /// </remarks> 53 /// </remarks>
54 54
55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")]
56 public class MapImageServiceModule : ISharedRegionModule 56 public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule
57 { 57 {
58 private static readonly ILog m_log = 58 private static readonly ILog m_log =
59 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60 private static string LogHeader = "[MAP IMAGE SERVICE MODULE]:";
60 61
61 private bool m_enabled = false; 62 private bool m_enabled = false;
62 private IMapImageService m_MapService; 63 private IMapImageService m_MapService;
@@ -65,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
65 66
66 private int m_refreshtime = 0; 67 private int m_refreshtime = 0;
67 private int m_lastrefresh = 0; 68 private int m_lastrefresh = 0;
68 private System.Timers.Timer m_refreshTimer = new System.Timers.Timer(); 69 private System.Timers.Timer m_refreshTimer;
69 70
70 #region ISharedRegionModule 71 #region ISharedRegionModule
71 72
@@ -75,7 +76,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
75 public void Close() { } 76 public void Close() { }
76 public void PostInitialise() { } 77 public void PostInitialise() { }
77 78
78
79 ///<summary> 79 ///<summary>
80 /// 80 ///
81 ///</summary> 81 ///</summary>
@@ -94,14 +94,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
94 return; 94 return;
95 95
96 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); 96 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime"));
97 if (refreshminutes <= 0) 97
98 // if refresh is less than zero, disable the module
99 if (refreshminutes < 0)
98 { 100 {
99 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: No refresh time given in config. Module disabled."); 101 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled.");
100 return; 102 return;
101 } 103 }
102 104
103 m_refreshtime = refreshminutes * 60 * 1000; // convert from minutes to ms
104
105 string service = config.GetString("LocalServiceModule", string.Empty); 105 string service = config.GetString("LocalServiceModule", string.Empty);
106 if (service == string.Empty) 106 if (service == string.Empty)
107 { 107 {
@@ -116,15 +116,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
116 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service); 116 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service);
117 return; 117 return;
118 } 118 }
119
120 // we don't want the timer if the interval is zero, but we still want this module enables
121 if(refreshminutes > 0)
122 {
123 m_refreshtime = refreshminutes * 60 * 1000; // convert from minutes to ms
124
125 m_refreshTimer = new System.Timers.Timer();
126 m_refreshTimer.Enabled = true;
127 m_refreshTimer.AutoReset = true;
128 m_refreshTimer.Interval = m_refreshtime;
129 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
119 130
120 m_refreshTimer.Enabled = true; 131 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}",
121 m_refreshTimer.AutoReset = true;
122 m_refreshTimer.Interval = m_refreshtime;
123 m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh);
124
125 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0}min and service object {1}",
126 refreshminutes, service); 132 refreshminutes, service);
127 133 }
134 else
135 {
136 m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with no refresh and service object {0}", service);
137 }
128 m_enabled = true; 138 m_enabled = true;
129 } 139 }
130 140
@@ -133,7 +143,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
133 ///</summary> 143 ///</summary>
134 public void AddRegion(Scene scene) 144 public void AddRegion(Scene scene)
135 { 145 {
136 if (! m_enabled) 146 if (!m_enabled)
137 return; 147 return;
138 148
139 // Every shared region module has to maintain an indepedent list of 149 // Every shared region module has to maintain an indepedent list of
@@ -141,7 +151,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
141 lock (m_scenes) 151 lock (m_scenes)
142 m_scenes[scene.RegionInfo.RegionID] = scene; 152 m_scenes[scene.RegionInfo.RegionID] = scene;
143 153
144 scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); }; 154 // v2 Map generation on startup is now handled by scene to allow bmp to be shared with
155 // v1 service and not generate map tiles twice as was previous behavior
156 //scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
157
158 scene.RegisterModuleInterface<IMapImageUploadModule>(this);
145 } 159 }
146 160
147 ///<summary> 161 ///<summary>
@@ -188,42 +202,101 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
188 m_lastrefresh = Util.EnvironmentTickCount(); 202 m_lastrefresh = Util.EnvironmentTickCount();
189 } 203 }
190 204
205 public void UploadMapTile(IScene scene, Bitmap mapTile)
206 {
207 if (mapTile == null)
208 {
209 m_log.WarnFormat("{0} Cannot upload null image", LogHeader);
210 return;
211 }
212
213 m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
214
215 // mapTile.Save( // DEBUG DEBUG
216 // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY),
217 // ImageFormat.Jpeg);
218 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
219 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
220 {
221 ConvertAndUploadMaptile(mapTile,
222 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
223 scene.RegionInfo.RegionName);
224 }
225 else
226 {
227 // For larger regions (varregion) we must cut the region image into legacy sized
228 // pieces since that is how the maptile system works.
229 // Note the assumption that varregions are always a multiple of legacy size.
230 for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
231 {
232 for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
233 {
234 // Images are addressed from the upper left corner so have to do funny
235 // math to pick out the sub-tile since regions are numbered from
236 // the lower left.
237 Rectangle rect = new Rectangle(
238 (int)xx,
239 mapTile.Height - (int)yy - (int)Constants.RegionSize,
240 (int)Constants.RegionSize, (int)Constants.RegionSize);
241 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
242 {
243 ConvertAndUploadMaptile(subMapTile,
244 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
245 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
246 scene.Name);
247 }
248 }
249 }
250 }
251 }
252
191 ///<summary> 253 ///<summary>
192 /// 254 ///
193 ///</summary> 255 ///</summary>
194 private void UploadMapTile(IScene scene) 256 private void UploadMapTile(IScene scene)
195 { 257 {
196 m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: upload maptile for {0}", scene.RegionInfo.RegionName);
197
198 // Create a JPG map tile and upload it to the AddMapTile API 258 // Create a JPG map tile and upload it to the AddMapTile API
199 byte[] jpgData = Utils.EmptyBytes;
200 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); 259 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
201 if (tileGenerator == null) 260 if (tileGenerator == null)
202 { 261 {
203 m_log.Warn("[MAP IMAGE SERVICE MODULE]: Cannot upload PNG map tile without an ImageGenerator"); 262 m_log.WarnFormat("{0} Cannot upload map tile without an ImageGenerator", LogHeader);
204 return; 263 return;
205 } 264 }
206 265
207 using (Image mapTile = tileGenerator.CreateMapTile()) 266 using (Bitmap mapTile = tileGenerator.CreateMapTile())
208 { 267 {
209 using (MemoryStream stream = new MemoryStream()) 268 if (mapTile != null)
269 {
270 UploadMapTile(scene, mapTile);
271 }
272 else
210 { 273 {
211 mapTile.Save(stream, ImageFormat.Jpeg); 274 m_log.WarnFormat("{0} Tile image generation failed", LogHeader);
212 jpgData = stream.ToArray();
213 } 275 }
214 } 276 }
277 }
215 278
216 if (jpgData == Utils.EmptyBytes) 279 private void ConvertAndUploadMaptile(Image tileImage, uint locX, uint locY, string regionName)
280 {
281 byte[] jpgData = Utils.EmptyBytes;
282
283 using (MemoryStream stream = new MemoryStream())
217 { 284 {
218 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Tile image generation failed"); 285 tileImage.Save(stream, ImageFormat.Jpeg);
219 return; 286 jpgData = stream.ToArray();
220 } 287 }
221 288 if (jpgData != Utils.EmptyBytes)
222 string reason = string.Empty; 289 {
223 if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason)) 290 string reason = string.Empty;
291 if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason))
292 {
293 m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader,
294 regionName, locX, locY, reason);
295 }
296 }
297 else
224 { 298 {
225 m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}", 299 m_log.WarnFormat("{0} Tile image generation failed for region {1}", LogHeader, regionName);
226 scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason);
227 } 300 }
228 } 301 }
229 } 302 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
index fd89428..bda354f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs
@@ -125,14 +125,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
125 public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) 125 public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
126 { 126 {
127 uint x, y; 127 uint x, y;
128 Utils.LongToUInts(regionHandle, out x, out y); 128 Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
129 129
130 foreach (Scene s in m_Scenes) 130 foreach (Scene s in m_Scenes)
131 { 131 {
132 if (s.RegionInfo.RegionHandle == regionHandle) 132 if (s.RegionInfo.RegionHandle == regionHandle)
133 { 133 {
134 m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", 134 m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}",
135 thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize); 135 thisRegion.RegionName, s.Name, x, y );
136 136
137 //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); 137 //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour");
138 return s.IncomingHelloNeighbour(thisRegion); 138 return s.IncomingHelloNeighbour(thisRegion);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index 172bea1..50c252c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -69,7 +69,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
69 public void OnMakeRootAgent(ScenePresence sp) 69 public void OnMakeRootAgent(ScenePresence sp)
70 { 70 {
71// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); 71// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
72 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); 72 if (sp.PresenceType != PresenceType.Npc)
73 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID);
73 } 74 }
74 75
75 public void OnNewClient(IClientAPI client) 76 public void OnNewClient(IClientAPI client)
@@ -79,7 +80,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
79 80
80 public void OnConnectionClose(IClientAPI client) 81 public void OnConnectionClose(IClientAPI client)
81 { 82 {
82 if (!client.SceneAgent.IsChildAgent) 83 if (client != null && client.SceneAgent != null && !client.SceneAgent.IsChildAgent)
83 { 84 {
84// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); 85// m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
85 m_PresenceService.LogoutAgent(client.SessionId); 86 m_PresenceService.LogoutAgent(client.SessionId);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 3c18074..cc8203e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -46,11 +46,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 /// <summary> 48 /// <summary>
49 /// Version of this service
50 /// </summary>
51 private const string m_Version = "SIMULATION/0.1";
52
53 /// <summary>
54 /// Map region ID to scene. 49 /// Map region ID to scene.
55 /// </summary> 50 /// </summary>
56 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 51 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
@@ -62,28 +57,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
62 57
63 #region Region Module interface 58 #region Region Module interface
64 59
65 public void Initialise(IConfigSource config) 60 public void Initialise(IConfigSource configSource)
66 { 61 {
67 IConfig moduleConfig = config.Configs["Modules"]; 62 IConfig moduleConfig = configSource.Configs["Modules"];
68 if (moduleConfig != null) 63 if (moduleConfig != null)
69 { 64 {
70 string name = moduleConfig.GetString("SimulationServices", ""); 65 string name = moduleConfig.GetString("SimulationServices", "");
71 if (name == Name) 66 if (name == Name)
72 { 67 {
73 //IConfig userConfig = config.Configs["SimulationService"]; 68 InitialiseService(configSource);
74 //if (userConfig == null)
75 //{
76 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
77 // return;
78 //}
79 69
80 m_ModuleEnabled = true; 70 m_ModuleEnabled = true;
81 71
82 m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); 72 m_log.Info("[LOCAL SIMULATION CONNECTOR]: Local simulation enabled.");
83 } 73 }
84 } 74 }
85 } 75 }
86 76
77 public void InitialiseService(IConfigSource configSource)
78 {
79 }
80
87 public void PostInitialise() 81 public void PostInitialise()
88 { 82 {
89 } 83 }
@@ -160,7 +154,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
160 154
161 #endregion 155 #endregion
162 156
163 #region ISimulation 157 #region ISimulationService
164 158
165 public IScene GetScene(UUID regionId) 159 public IScene GetScene(UUID regionId)
166 { 160 {
@@ -191,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
191 * Agent-related communications 185 * Agent-related communications
192 */ 186 */
193 187
194 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) 188 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
195 { 189 {
196 if (destination == null) 190 if (destination == null)
197 { 191 {
@@ -203,7 +197,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
203 if (m_scenes.ContainsKey(destination.RegionID)) 197 if (m_scenes.ContainsKey(destination.RegionID))
204 { 198 {
205// m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); 199// m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
206 return m_scenes[destination.RegionID].NewUserConnection(aCircuit, teleportFlags, out reason); 200 return m_scenes[destination.RegionID].NewUserConnection(aCircuit, teleportFlags, source, out reason);
207 } 201 }
208 202
209 reason = "Did not find region " + destination.RegionName; 203 reason = "Did not find region " + destination.RegionName;
@@ -219,16 +213,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
219 { 213 {
220// m_log.DebugFormat( 214// m_log.DebugFormat(
221// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 215// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
222// s.RegionInfo.RegionName, destination.RegionHandle); 216// destination.RegionName, destination.RegionID);
223 217
224 return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); 218 return m_scenes[destination.RegionID].IncomingUpdateChildAgent(cAgentData);
225 } 219 }
226 220
227// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); 221// m_log.DebugFormat(
222// "[LOCAL COMMS]: Did not find region {0} {1} for ChildAgentUpdate",
223// destination.RegionName, destination.RegionID);
224
228 return false; 225 return false;
229 } 226 }
230 227
231 public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) 228 public bool UpdateAgent(GridRegion destination, AgentPosition agentPosition)
232 { 229 {
233 if (destination == null) 230 if (destination == null)
234 return false; 231 return false;
@@ -239,38 +236,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
239 // note that we really don't need the GridRegion for this call 236 // note that we really don't need the GridRegion for this call
240 foreach (Scene s in m_scenes.Values) 237 foreach (Scene s in m_scenes.Values)
241 { 238 {
242 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 239// m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
243 s.IncomingChildAgentDataUpdate(cAgentData); 240 s.IncomingUpdateChildAgent(agentPosition);
244 } 241 }
245 242
246 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); 243 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
247 return true; 244 return true;
248 } 245 }
249 246
250 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 247 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, EntityTransferContext ctx, out string reason)
251 {
252 agent = null;
253
254 if (destination == null)
255 return false;
256
257 if (m_scenes.ContainsKey(destination.RegionID))
258 {
259// m_log.DebugFormat(
260// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
261// s.RegionInfo.RegionName, destination.RegionHandle);
262
263 return m_scenes[destination.RegionID].IncomingRetrieveRootAgent(id, out agent);
264 }
265
266 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
267 return false;
268 }
269
270 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
271 { 248 {
272 reason = "Communications failure"; 249 reason = "Communications failure";
273 version = m_Version;
274 if (destination == null) 250 if (destination == null)
275 return false; 251 return false;
276 252
@@ -279,8 +255,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
279// m_log.DebugFormat( 255// m_log.DebugFormat(
280// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 256// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
281// s.RegionInfo.RegionName, destination.RegionHandle); 257// s.RegionInfo.RegionName, destination.RegionHandle);
258 uint sizeX = m_scenes[destination.RegionID].RegionInfo.RegionSizeX;
259 uint sizeY = m_scenes[destination.RegionID].RegionInfo.RegionSizeY;
282 260
283 return m_scenes[destination.RegionID].QueryAccess(id, position, out reason); 261 // Var regions here, and the requesting simulator is in an older version.
262 // We will forbide this, because it crashes the viewers
263 if (ctx.OutboundVersion < 0.3f && (sizeX != 256 || sizeY != 256))
264 {
265 reason = "Destination is a variable-sized region, and source is an old simulator. Consider upgrading.";
266 m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Request to access this variable-sized region from older simulator was denied");
267 return false;
268
269 }
270
271 return m_scenes[destination.RegionID].QueryAccess(agentID, agentHomeURI, viaTeleport, position, features, out reason);
284 } 272 }
285 273
286 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 274 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
@@ -303,7 +291,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
303 return false; 291 return false;
304 } 292 }
305 293
306 public bool CloseAgent(GridRegion destination, UUID id) 294 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
307 { 295 {
308 if (destination == null) 296 if (destination == null)
309 return false; 297 return false;
@@ -314,7 +302,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
314// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 302// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
315// s.RegionInfo.RegionName, destination.RegionHandle); 303// s.RegionInfo.RegionName, destination.RegionHandle);
316 304
317 Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); }); 305 m_scenes[destination.RegionID].CloseAgent(id, false, auth_token);
318 return true; 306 return true;
319 } 307 }
320 308
@@ -356,7 +344,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
356 return false; 344 return false;
357 } 345 }
358 346
359 #endregion /* IInterregionComms */ 347 #endregion
360 348
361 #region Misc 349 #region Misc
362 350
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index b2a1b23..1e095ca 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
@@ -37,7 +38,6 @@ using Nini.Config;
37using OpenMetaverse; 38using OpenMetaverse;
38using OpenMetaverse.StructuredData; 39using OpenMetaverse.StructuredData;
39using OpenSim.Framework; 40using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Serialization; 43using OpenSim.Region.Framework.Scenes.Serialization;
@@ -50,9 +50,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteSimulationConnectorModule")] 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteSimulationConnectorModule")]
51 public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService 51 public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService
52 { 52 {
53 private bool initialized = false;
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 54
55 private bool initialized = false;
56 protected bool m_enabled = false; 56 protected bool m_enabled = false;
57 protected Scene m_aScene; 57 protected Scene m_aScene;
58 // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module 58 // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module
@@ -60,31 +60,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
60 protected SimulationServiceConnector m_remoteConnector; 60 protected SimulationServiceConnector m_remoteConnector;
61 61
62 protected bool m_safemode; 62 protected bool m_safemode;
63 protected IPAddress m_thisIP;
64 63
65 #region Region Module interface 64 #region Region Module interface
66 65
67 public virtual void Initialise(IConfigSource config) 66 public virtual void Initialise(IConfigSource configSource)
68 { 67 {
69 68 IConfig moduleConfig = configSource.Configs["Modules"];
70 IConfig moduleConfig = config.Configs["Modules"];
71 if (moduleConfig != null) 69 if (moduleConfig != null)
72 { 70 {
73 string name = moduleConfig.GetString("SimulationServices", ""); 71 string name = moduleConfig.GetString("SimulationServices", "");
74 if (name == Name) 72 if (name == Name)
75 { 73 {
76 //IConfig userConfig = config.Configs["SimulationService"]; 74 m_localBackend = new LocalSimulationConnectorModule();
77 //if (userConfig == null) 75
78 //{ 76 m_localBackend.InitialiseService(configSource);
79 // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
80 // return;
81 //}
82 77
83 m_remoteConnector = new SimulationServiceConnector(); 78 m_remoteConnector = new SimulationServiceConnector();
84 79
85 m_enabled = true; 80 m_enabled = true;
86 81
87 m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); 82 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Remote simulation enabled.");
88 } 83 }
89 } 84 }
90 } 85 }
@@ -142,16 +137,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
142 } 137 }
143 138
144 protected virtual void InitOnce(Scene scene) 139 protected virtual void InitOnce(Scene scene)
145 { 140 {
146 m_localBackend = new LocalSimulationConnectorModule();
147 m_aScene = scene; 141 m_aScene = scene;
148 //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); 142 //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
149 m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
150 } 143 }
151 144
152 #endregion 145 #endregion
153 146
154 #region IInterregionComms 147 #region ISimulationService
155 148
156 public IScene GetScene(UUID regionId) 149 public IScene GetScene(UUID regionId)
157 { 150 {
@@ -167,7 +160,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
167 * Agent-related communications 160 * Agent-related communications
168 */ 161 */
169 162
170 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) 163 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
171 { 164 {
172 if (destination == null) 165 if (destination == null)
173 { 166 {
@@ -177,13 +170,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
177 } 170 }
178 171
179 // Try local first 172 // Try local first
180 if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) 173 if (m_localBackend.CreateAgent(source, destination, aCircuit, teleportFlags, out reason))
181 return true; 174 return true;
182 175
183 // else do the remote thing 176 // else do the remote thing
184 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 177 if (!m_localBackend.IsLocalRegion(destination.RegionID))
185 { 178 {
186 return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); 179 return m_remoteConnector.CreateAgent(source, destination, aCircuit, teleportFlags, out reason);
187 } 180 }
188 return false; 181 return false;
189 } 182 }
@@ -194,7 +187,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
194 return false; 187 return false;
195 188
196 // Try local first 189 // Try local first
197 if (m_localBackend.IsLocalRegion(destination.RegionHandle)) 190 if (m_localBackend.IsLocalRegion(destination.RegionID))
198 return m_localBackend.UpdateAgent(destination, cAgentData); 191 return m_localBackend.UpdateAgent(destination, cAgentData);
199 192
200 return m_remoteConnector.UpdateAgent(destination, cAgentData); 193 return m_remoteConnector.UpdateAgent(destination, cAgentData);
@@ -206,45 +199,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
206 return false; 199 return false;
207 200
208 // Try local first 201 // Try local first
209 if (m_localBackend.IsLocalRegion(destination.RegionHandle)) 202 if (m_localBackend.IsLocalRegion(destination.RegionID))
210 return m_localBackend.UpdateAgent(destination, cAgentData); 203 return m_localBackend.UpdateAgent(destination, cAgentData);
211 204
212 return m_remoteConnector.UpdateAgent(destination, cAgentData); 205 return m_remoteConnector.UpdateAgent(destination, cAgentData);
213 } 206 }
214 207
215 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) 208 public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, EntityTransferContext ctx, out string reason)
216 {
217 agent = null;
218
219 if (destination == null)
220 return false;
221
222 // Try local first
223 if (m_localBackend.RetrieveAgent(destination, id, out agent))
224 return true;
225
226 // else do the remote thing
227 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
228 return m_remoteConnector.RetrieveAgent(destination, id, out agent);
229
230 return false;
231 }
232
233 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
234 { 209 {
235 reason = "Communications failure"; 210 reason = "Communications failure";
236 version = "Unknown";
237 211
238 if (destination == null) 212 if (destination == null)
239 return false; 213 return false;
240 214
241 // Try local first 215 // Try local first
242 if (m_localBackend.QueryAccess(destination, id, position, out version, out reason)) 216 if (m_localBackend.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason))
243 return true; 217 return true;
244 218
245 // else do the remote thing 219 // else do the remote thing
246 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 220 if (!m_localBackend.IsLocalRegion(destination.RegionID))
247 return m_remoteConnector.QueryAccess(destination, id, position, out version, out reason); 221 return m_remoteConnector.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, features, ctx, out reason);
248 222
249 return false; 223 return false;
250 } 224 }
@@ -263,18 +237,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
263 } 237 }
264 238
265 239
266 public bool CloseAgent(GridRegion destination, UUID id) 240 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
267 { 241 {
268 if (destination == null) 242 if (destination == null)
269 return false; 243 return false;
270 244
271 // Try local first 245 // Try local first
272 if (m_localBackend.CloseAgent(destination, id)) 246 if (m_localBackend.CloseAgent(destination, id, auth_token))
273 return true; 247 return true;
274 248
275 // else do the remote thing 249 // else do the remote thing
276 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 250 if (!m_localBackend.IsLocalRegion(destination.RegionID))
277 return m_remoteConnector.CloseAgent(destination, id); 251 return m_remoteConnector.CloseAgent(destination, id, auth_token);
278 252
279 return false; 253 return false;
280 } 254 }
@@ -296,12 +270,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
296 } 270 }
297 271
298 // else do the remote thing 272 // else do the remote thing
299 if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) 273 if (!m_localBackend.IsLocalRegion(destination.RegionID))
300 return m_remoteConnector.CreateObject(destination, newPosition, sog, isLocalCall); 274 return m_remoteConnector.CreateObject(destination, newPosition, sog, isLocalCall);
301 275
302 return false; 276 return false;
303 } 277 }
304 278
305 #endregion /* IInterregionComms */ 279 #endregion
306 } 280 }
307} 281}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index 529bfd7..6d4ac39 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -190,7 +190,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
190 // 190 //
191 public bool StoreUserAccount(UserAccount data) 191 public bool StoreUserAccount(UserAccount data)
192 { 192 {
193 return UserAccountService.StoreUserAccount(data); 193 bool ret = UserAccountService.StoreUserAccount(data);
194 if (ret)
195 m_Cache.Cache(data.PrincipalID, data);
196 return ret;
197 }
198
199 public void InvalidateCache(UUID userID)
200 {
201 m_Cache.Invalidate(userID);
194 } 202 }
195 203
196 #endregion 204 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index ddef75f..ed52e48 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -61,6 +61,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
61 //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); 61 //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
62 } 62 }
63 63
64 public void Invalidate(UUID userID)
65 {
66 m_UUIDCache.Remove(userID);
67 }
68
64 public UserAccount Get(UUID userID, out bool inCache) 69 public UserAccount Get(UUID userID, out bool inCache)
65 { 70 {
66 UserAccount account = null; 71 UserAccount account = null;