aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs23
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs75
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs43
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs13
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs55
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs19
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs22
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs20
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs27
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs27
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs74
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs16
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs38
13 files changed, 320 insertions, 132 deletions
diff --git a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
index 34df54a..5c31639 100644
--- a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs
@@ -32,6 +32,8 @@ using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Connectors.SimianGrid;
35 37
36namespace OpenSim.Services.Connectors 38namespace OpenSim.Services.Connectors
37{ 39{
@@ -41,7 +43,7 @@ namespace OpenSim.Services.Connectors
41 LogManager.GetLogger( 43 LogManager.GetLogger(
42 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
43 45
44 private Dictionary<string, AssetServicesConnector> m_connectors = new Dictionary<string, AssetServicesConnector>(); 46 private Dictionary<string, IAssetService> m_connectors = new Dictionary<string, IAssetService>();
45 47
46 public HGAssetServiceConnector(IConfigSource source) 48 public HGAssetServiceConnector(IConfigSource source)
47 { 49 {
@@ -81,7 +83,7 @@ namespace OpenSim.Services.Connectors
81 83
82 private IAssetService GetConnector(string url) 84 private IAssetService GetConnector(string url)
83 { 85 {
84 AssetServicesConnector connector = null; 86 IAssetService connector = null;
85 lock (m_connectors) 87 lock (m_connectors)
86 { 88 {
87 if (m_connectors.ContainsKey(url)) 89 if (m_connectors.ContainsKey(url))
@@ -90,12 +92,17 @@ namespace OpenSim.Services.Connectors
90 } 92 }
91 else 93 else
92 { 94 {
93 // We're instantiating this class explicitly, but this won't 95 // Still not as flexible as I would like this to be,
94 // work in general, because the remote grid may be running 96 // but good enough for now
95 // an asset server that has a different protocol. 97 string connectorType = new HeloServicesConnector(url).Helo();
96 // Eventually we will want a piece of protocol asking 98 m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
97 // the remote server about its kind. Definitely cool thing to do! 99 if (connectorType == "opensim-simian")
98 connector = new AssetServicesConnector(url); 100 {
101 connector = new SimianAssetServiceConnector(url);
102 }
103 else
104 connector = new AssetServicesConnector(url);
105
99 m_connectors.Add(url, connector); 106 m_connectors.Add(url, connector);
100 } 107 }
101 } 108 }
diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs
new file mode 100644
index 0000000..7b166c1
--- /dev/null
+++ b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs
@@ -0,0 +1,75 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Net;
31using System.Reflection;
32using Nini.Config;
33
34namespace OpenSim.Services.Connectors
35{
36 public class HeloServicesConnector
37 {
38 private static readonly ILog m_log =
39 LogManager.GetLogger(
40 MethodBase.GetCurrentMethod().DeclaringType);
41
42 private string m_ServerURI = String.Empty;
43
44 public HeloServicesConnector()
45 {
46 }
47
48 public HeloServicesConnector(string serverURI)
49 {
50 m_ServerURI = serverURI.TrimEnd('/');
51 }
52
53
54 public virtual string Helo()
55 {
56 HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI + "/helo");
57
58 try
59 {
60 WebResponse response = req.GetResponse();
61 if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
62 return string.Empty;
63 return response.Headers.Get("X-Handlers-Provided");
64 }
65 catch (Exception e)
66 {
67 m_log.DebugFormat("[HELO SERVICE]: Unable to perform HELO request to {0}: {1}", m_ServerURI, e.Message);
68 }
69
70 // fail
71 return string.Empty;
72 }
73
74 }
75}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 7fa086a..6d3c64a 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -66,20 +66,34 @@ namespace OpenSim.Services.Connectors.Hypergrid
66 { 66 {
67 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message); 67 m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", m_ServerURL, e.Message);
68 } 68 }
69 m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL);
69 } 70 }
70 71
71 public UserAgentServiceConnector(IConfigSource config) 72 public UserAgentServiceConnector(IConfigSource config)
72 { 73 {
73 } 74 IConfig serviceConfig = config.Configs["UserAgentService"];
75 if (serviceConfig == null)
76 {
77 m_log.Error("[USER AGENT CONNECTOR]: UserAgentService missing from ini");
78 throw new Exception("UserAgent connector init error");
79 }
74 80
75 public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason) 81 string serviceURI = serviceConfig.GetString("UserAgentServerURI",
76 { 82 String.Empty);
77 // not available over remote calls 83
78 reason = "Method not available over remote calls"; 84 if (serviceURI == String.Empty)
79 return false; 85 {
86 m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService");
87 throw new Exception("UserAgent connector init error");
88 }
89 m_ServerURL = serviceURI;
90
91 m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL);
80 } 92 }
81 93
82 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) 94
95 // The Login service calls this interface with a non-null [client] ipaddress
96 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason)
83 { 97 {
84 reason = String.Empty; 98 reason = String.Empty;
85 99
@@ -90,7 +104,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
90 return false; 104 return false;
91 } 105 }
92 106
93 string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/"; 107 string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/";
94 108
95 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); 109 Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri);
96 110
@@ -102,7 +116,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
102 //AgentCreateRequest.Headers.Add("Authorization", authKey); 116 //AgentCreateRequest.Headers.Add("Authorization", authKey);
103 117
104 // Fill it in 118 // Fill it in
105 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination); 119 OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress);
106 120
107 string strBuffer = ""; 121 string strBuffer = "";
108 byte[] buffer = new byte[1]; 122 byte[] buffer = new byte[1];
@@ -199,7 +213,14 @@ namespace OpenSim.Services.Connectors.Hypergrid
199 213
200 } 214 }
201 215
202 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination) 216
217 // The simulators call this interface
218 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
219 {
220 return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason);
221 }
222
223 protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress)
203 { 224 {
204 OSDMap args = null; 225 OSDMap args = null;
205 try 226 try
@@ -217,6 +238,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
217 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); 238 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
218 args["destination_name"] = OSD.FromString(destination.RegionName); 239 args["destination_name"] = OSD.FromString(destination.RegionName);
219 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 240 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
241 if (ipaddress != null)
242 args["client_ip"] = OSD.FromString(ipaddress.Address.ToString());
220 243
221 return args; 244 return args;
222 } 245 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
index a871d07..67a06f3 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
@@ -26,11 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
30using System.Reflection; 29using System.Reflection;
31using OpenSim.Framework; 30using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34using OpenMetaverse; 32using OpenMetaverse;
35using log4net; 33using log4net;
36 34
@@ -71,7 +69,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
71 public void OnMakeRootAgent(ScenePresence sp) 69 public void OnMakeRootAgent(ScenePresence sp)
72 { 70 {
73 m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); 71 m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
74 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 72 Util.FireAndForget(delegate(object o)
73 {
74 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
75 });
75 } 76 }
76 77
77 public void OnNewClient(IClientAPI client) 78 public void OnNewClient(IClientAPI client)
@@ -107,7 +108,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
107 108
108 void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID) 109 void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID)
109 { 110 {
110 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 111 // Asynchronously update the position stored in the session table for this agent
112 Util.FireAndForget(delegate(object o)
113 {
114 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
115 });
111 } 116 }
112 } 117 }
113} 118}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
index 3a4f84f..30d3147 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
55 55
56 private string m_serverUrl = String.Empty; 56 private string m_serverUrl = String.Empty;
57 private IImprovedAssetCache m_cache; 57 private IImprovedAssetCache m_cache;
58 private bool m_Enabled = false;
58 59
59 #region ISharedRegionModule 60 #region ISharedRegionModule
60 61
@@ -73,18 +74,34 @@ namespace OpenSim.Services.Connectors.SimianGrid
73 74
74 public SimianAssetServiceConnector() { } 75 public SimianAssetServiceConnector() { }
75 public string Name { get { return "SimianAssetServiceConnector"; } } 76 public string Name { get { return "SimianAssetServiceConnector"; } }
76 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IAssetService>(this); } } 77 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAssetService>(this); } }
77 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IAssetService>(this); } } 78 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAssetService>(this); } }
78 79
79 #endregion ISharedRegionModule 80 #endregion ISharedRegionModule
80 81
81 public SimianAssetServiceConnector(IConfigSource source) 82 public SimianAssetServiceConnector(IConfigSource source)
82 { 83 {
83 Initialise(source); 84 CommonInit(source);
85 }
86
87 public SimianAssetServiceConnector(string url)
88 {
89 m_serverUrl = url;
84 } 90 }
85 91
86 public void Initialise(IConfigSource source) 92 public void Initialise(IConfigSource source)
87 { 93 {
94 IConfig moduleConfig = source.Configs["Modules"];
95 if (moduleConfig != null)
96 {
97 string name = moduleConfig.GetString("AssetServices", "");
98 if (name == Name)
99 CommonInit(source);
100 }
101 }
102
103 private void CommonInit(IConfigSource source)
104 {
88 IConfig gridConfig = source.Configs["AssetService"]; 105 IConfig gridConfig = source.Configs["AssetService"];
89 if (gridConfig != null) 106 if (gridConfig != null)
90 { 107 {
@@ -99,12 +116,20 @@ namespace OpenSim.Services.Connectors.SimianGrid
99 116
100 if (String.IsNullOrEmpty(m_serverUrl)) 117 if (String.IsNullOrEmpty(m_serverUrl))
101 m_log.Info("[SIMIAN ASSET CONNECTOR]: No AssetServerURI specified, disabling connector"); 118 m_log.Info("[SIMIAN ASSET CONNECTOR]: No AssetServerURI specified, disabling connector");
119 else
120 m_Enabled = true;
102 } 121 }
103 122
104 #region IAssetService 123 #region IAssetService
105 124
106 public AssetBase Get(string id) 125 public AssetBase Get(string id)
107 { 126 {
127 if (String.IsNullOrEmpty(m_serverUrl))
128 {
129 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
130 throw new InvalidOperationException();
131 }
132
108 // Cache fetch 133 // Cache fetch
109 if (m_cache != null) 134 if (m_cache != null)
110 { 135 {
@@ -131,6 +156,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
131 /// <returns></returns> 156 /// <returns></returns>
132 public AssetMetadata GetMetadata(string id) 157 public AssetMetadata GetMetadata(string id)
133 { 158 {
159 if (String.IsNullOrEmpty(m_serverUrl))
160 {
161 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
162 throw new InvalidOperationException();
163 }
164
134 AssetMetadata metadata = null; 165 AssetMetadata metadata = null;
135 166
136 // Cache fetch 167 // Cache fetch
@@ -202,6 +233,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
202 /// <returns>True if the id was parseable, false otherwise</returns> 233 /// <returns>True if the id was parseable, false otherwise</returns>
203 public bool Get(string id, Object sender, AssetRetrieved handler) 234 public bool Get(string id, Object sender, AssetRetrieved handler)
204 { 235 {
236 if (String.IsNullOrEmpty(m_serverUrl))
237 {
238 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
239 throw new InvalidOperationException();
240 }
241
205 // Cache fetch 242 // Cache fetch
206 if (m_cache != null) 243 if (m_cache != null)
207 { 244 {
@@ -232,6 +269,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
232 /// <returns></returns> 269 /// <returns></returns>
233 public string Store(AssetBase asset) 270 public string Store(AssetBase asset)
234 { 271 {
272 if (String.IsNullOrEmpty(m_serverUrl))
273 {
274 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
275 throw new InvalidOperationException();
276 }
277
235 bool storedInCache = false; 278 bool storedInCache = false;
236 string errorMessage = null; 279 string errorMessage = null;
237 280
@@ -364,6 +407,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
364 /// <returns></returns> 407 /// <returns></returns>
365 public bool Delete(string id) 408 public bool Delete(string id)
366 { 409 {
410 if (String.IsNullOrEmpty(m_serverUrl))
411 {
412 m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured");
413 throw new InvalidOperationException();
414 }
415
367 //string errorMessage = String.Empty; 416 //string errorMessage = String.Empty;
368 string url = m_serverUrl + id; 417 string url = m_serverUrl + id;
369 418
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index f1c2575..51a09f8 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private string m_serverUrl = String.Empty; 53 private string m_serverUrl = String.Empty;
54 private bool m_Enabled = false;
54 55
55 #region ISharedRegionModule 56 #region ISharedRegionModule
56 57
@@ -61,18 +62,29 @@ namespace OpenSim.Services.Connectors.SimianGrid
61 62
62 public SimianAuthenticationServiceConnector() { } 63 public SimianAuthenticationServiceConnector() { }
63 public string Name { get { return "SimianAuthenticationServiceConnector"; } } 64 public string Name { get { return "SimianAuthenticationServiceConnector"; } }
64 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IAuthenticationService>(this); } } 65 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAuthenticationService>(this); } }
65 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IAuthenticationService>(this); } } 66 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAuthenticationService>(this); } }
66 67
67 #endregion ISharedRegionModule 68 #endregion ISharedRegionModule
68 69
69 public SimianAuthenticationServiceConnector(IConfigSource source) 70 public SimianAuthenticationServiceConnector(IConfigSource source)
70 { 71 {
71 Initialise(source); 72 CommonInit(source);
72 } 73 }
73 74
74 public void Initialise(IConfigSource source) 75 public void Initialise(IConfigSource source)
75 { 76 {
77 IConfig moduleConfig = source.Configs["Modules"];
78 if (moduleConfig != null)
79 {
80 string name = moduleConfig.GetString("AuthenticationServices", "");
81 if (name == Name)
82 CommonInit(source);
83 }
84 }
85
86 private void CommonInit(IConfigSource source)
87 {
76 IConfig gridConfig = source.Configs["AuthenticationService"]; 88 IConfig gridConfig = source.Configs["AuthenticationService"];
77 if (gridConfig != null) 89 if (gridConfig != null)
78 { 90 {
@@ -82,6 +94,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
82 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 94 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
83 serviceUrl = serviceUrl + '/'; 95 serviceUrl = serviceUrl + '/';
84 m_serverUrl = serviceUrl; 96 m_serverUrl = serviceUrl;
97 m_Enabled = true;
85 } 98 }
86 } 99 }
87 100
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index c2e20a3..4d0d53e 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -28,8 +28,6 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.IO;
32using System.Net;
33using System.Reflection; 31using System.Reflection;
34using log4net; 32using log4net;
35using Mono.Addins; 33using Mono.Addins;
@@ -37,7 +35,6 @@ using Nini.Config;
37using OpenSim.Framework; 35using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
40using OpenSim.Server.Base;
41using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
42using OpenMetaverse; 39using OpenMetaverse;
43using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
@@ -56,6 +53,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
56// private static string ZeroID = UUID.Zero.ToString(); 53// private static string ZeroID = UUID.Zero.ToString();
57 54
58 private string m_serverUrl = String.Empty; 55 private string m_serverUrl = String.Empty;
56 private bool m_Enabled = false;
59 57
60 #region ISharedRegionModule 58 #region ISharedRegionModule
61 59
@@ -66,18 +64,29 @@ namespace OpenSim.Services.Connectors.SimianGrid
66 64
67 public SimianAvatarServiceConnector() { } 65 public SimianAvatarServiceConnector() { }
68 public string Name { get { return "SimianAvatarServiceConnector"; } } 66 public string Name { get { return "SimianAvatarServiceConnector"; } }
69 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IAvatarService>(this); } } 67 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IAvatarService>(this); } }
70 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IAvatarService>(this); } } 68 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IAvatarService>(this); } }
71 69
72 #endregion ISharedRegionModule 70 #endregion ISharedRegionModule
73 71
74 public SimianAvatarServiceConnector(IConfigSource source) 72 public SimianAvatarServiceConnector(IConfigSource source)
75 { 73 {
76 Initialise(source); 74 CommonInit(source);
77 } 75 }
78 76
79 public void Initialise(IConfigSource source) 77 public void Initialise(IConfigSource source)
80 { 78 {
79 IConfig moduleConfig = source.Configs["Modules"];
80 if (moduleConfig != null)
81 {
82 string name = moduleConfig.GetString("AvatarServices", "");
83 if (name == Name)
84 CommonInit(source);
85 }
86 }
87
88 private void CommonInit(IConfigSource source)
89 {
81 IConfig gridConfig = source.Configs["AvatarService"]; 90 IConfig gridConfig = source.Configs["AvatarService"];
82 if (gridConfig != null) 91 if (gridConfig != null)
83 { 92 {
@@ -87,6 +96,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
87 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 96 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
88 serviceUrl = serviceUrl + '/'; 97 serviceUrl = serviceUrl + '/';
89 m_serverUrl = serviceUrl; 98 m_serverUrl = serviceUrl;
99 m_Enabled = true;
90 } 100 }
91 } 101 }
92 102
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
index 1afb1e1..6f2d735 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs
@@ -30,13 +30,10 @@ using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Mono.Addins;
34using Nini.Config; 33using Nini.Config;
35using OpenMetaverse; 34using OpenMetaverse;
36using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 36using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
41 38
42using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; 39using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
@@ -46,8 +43,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
46 /// <summary> 43 /// <summary>
47 /// Stores and retrieves friend lists from the SimianGrid backend 44 /// Stores and retrieves friend lists from the SimianGrid backend
48 /// </summary> 45 /// </summary>
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 46 public class SimianFriendsServiceConnector : IFriendsService
50 public class SimianFriendsServiceConnector : IFriendsService, ISharedRegionModule
51 { 47 {
52 private static readonly ILog m_log = 48 private static readonly ILog m_log =
53 LogManager.GetLogger( 49 LogManager.GetLogger(
@@ -55,20 +51,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
55 51
56 private string m_serverUrl = String.Empty; 52 private string m_serverUrl = String.Empty;
57 53
58 #region ISharedRegionModule
59
60 public Type ReplaceableInterface { get { return null; } }
61 public void RegionLoaded(Scene scene) { }
62 public void PostInitialise() { }
63 public void Close() { }
64
65 public SimianFriendsServiceConnector() { }
66 public string Name { get { return "SimianFriendsServiceConnector"; } }
67 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IFriendsService>(this); } }
68 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IFriendsService>(this); } }
69
70 #endregion ISharedRegionModule
71
72 public SimianFriendsServiceConnector(IConfigSource source) 54 public SimianFriendsServiceConnector(IConfigSource source)
73 { 55 {
74 Initialise(source); 56 Initialise(source);
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 9d67ccb..4409d5c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
60 60
61 private string m_serverUrl = String.Empty; 61 private string m_serverUrl = String.Empty;
62 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 62 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
63 private bool m_Enabled = false;
63 64
64 #region ISharedRegionModule 65 #region ISharedRegionModule
65 66
@@ -72,32 +73,47 @@ namespace OpenSim.Services.Connectors.SimianGrid
72 public string Name { get { return "SimianGridServiceConnector"; } } 73 public string Name { get { return "SimianGridServiceConnector"; } }
73 public void AddRegion(Scene scene) 74 public void AddRegion(Scene scene)
74 { 75 {
76 if (!m_Enabled)
77 return;
78
75 // Every shared region module has to maintain an indepedent list of 79 // Every shared region module has to maintain an indepedent list of
76 // currently running regions 80 // currently running regions
77 lock (m_scenes) 81 lock (m_scenes)
78 m_scenes[scene.RegionInfo.RegionID] = scene; 82 m_scenes[scene.RegionInfo.RegionID] = scene;
79 83
80 if (!String.IsNullOrEmpty(m_serverUrl)) 84 scene.RegisterModuleInterface<IGridService>(this);
81 scene.RegisterModuleInterface<IGridService>(this);
82 } 85 }
83 public void RemoveRegion(Scene scene) 86 public void RemoveRegion(Scene scene)
84 { 87 {
88 if (!m_Enabled)
89 return;
90
85 lock (m_scenes) 91 lock (m_scenes)
86 m_scenes.Remove(scene.RegionInfo.RegionID); 92 m_scenes.Remove(scene.RegionInfo.RegionID);
87 93
88 if (!String.IsNullOrEmpty(m_serverUrl)) 94 scene.UnregisterModuleInterface<IGridService>(this);
89 scene.UnregisterModuleInterface<IGridService>(this);
90 } 95 }
91 96
92 #endregion ISharedRegionModule 97 #endregion ISharedRegionModule
93 98
94 public SimianGridServiceConnector(IConfigSource source) 99 public SimianGridServiceConnector(IConfigSource source)
95 { 100 {
96 Initialise(source); 101 CommonInit(source);
97 } 102 }
98 103
99 public void Initialise(IConfigSource source) 104 public void Initialise(IConfigSource source)
100 { 105 {
106 IConfig moduleConfig = source.Configs["Modules"];
107 if (moduleConfig != null)
108 {
109 string name = moduleConfig.GetString("GridServices", "");
110 if (name == Name)
111 CommonInit(source);
112 }
113 }
114
115 private void CommonInit(IConfigSource source)
116 {
101 IConfig gridConfig = source.Configs["GridService"]; 117 IConfig gridConfig = source.Configs["GridService"];
102 if (gridConfig != null) 118 if (gridConfig != null)
103 { 119 {
@@ -107,6 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
107 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 123 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
108 serviceUrl = serviceUrl + '/'; 124 serviceUrl = serviceUrl + '/';
109 m_serverUrl = serviceUrl; 125 m_serverUrl = serviceUrl;
126 m_Enabled = true;
110 } 127 }
111 } 128 }
112 129
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 63aaad7..21ad4ab 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -37,7 +37,6 @@ using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Server.Base;
41using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
42 41
43namespace OpenSim.Services.Connectors.SimianGrid 42namespace OpenSim.Services.Connectors.SimianGrid
@@ -70,6 +69,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
70 private string m_serverUrl = String.Empty; 69 private string m_serverUrl = String.Empty;
71 private string m_userServerUrl = String.Empty; 70 private string m_userServerUrl = String.Empty;
72// private object m_gestureSyncRoot = new object(); 71// private object m_gestureSyncRoot = new object();
72 private bool m_Enabled = false;
73 73
74 #region ISharedRegionModule 74 #region ISharedRegionModule
75 75
@@ -80,18 +80,34 @@ namespace OpenSim.Services.Connectors.SimianGrid
80 80
81 public SimianInventoryServiceConnector() { } 81 public SimianInventoryServiceConnector() { }
82 public string Name { get { return "SimianInventoryServiceConnector"; } } 82 public string Name { get { return "SimianInventoryServiceConnector"; } }
83 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IInventoryService>(this); } } 83 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IInventoryService>(this); } }
84 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IInventoryService>(this); } } 84 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IInventoryService>(this); } }
85 85
86 #endregion ISharedRegionModule 86 #endregion ISharedRegionModule
87 87
88 public SimianInventoryServiceConnector(IConfigSource source) 88 public SimianInventoryServiceConnector(IConfigSource source)
89 { 89 {
90 Initialise(source); 90 CommonInit(source);
91 }
92
93 public SimianInventoryServiceConnector(string url)
94 {
95 m_serverUrl = url;
91 } 96 }
92 97
93 public void Initialise(IConfigSource source) 98 public void Initialise(IConfigSource source)
94 { 99 {
100 IConfig moduleConfig = source.Configs["Modules"];
101 if (moduleConfig != null)
102 {
103 string name = moduleConfig.GetString("InventoryServices", "");
104 if (name == Name)
105 CommonInit(source);
106 }
107 }
108
109 private void CommonInit(IConfigSource source)
110 {
95 IConfig gridConfig = source.Configs["InventoryService"]; 111 IConfig gridConfig = source.Configs["InventoryService"];
96 if (gridConfig != null) 112 if (gridConfig != null)
97 { 113 {
@@ -107,7 +123,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
107 { 123 {
108 serviceUrl = gridConfig.GetString("UserAccountServerURI"); 124 serviceUrl = gridConfig.GetString("UserAccountServerURI");
109 if (!String.IsNullOrEmpty(serviceUrl)) 125 if (!String.IsNullOrEmpty(serviceUrl))
126 {
110 m_userServerUrl = serviceUrl; 127 m_userServerUrl = serviceUrl;
128 m_Enabled = true;
129 }
111 } 130 }
112 } 131 }
113 } 132 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 778f3f4..a344594 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -28,17 +28,14 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Net;
32using System.Reflection; 31using System.Reflection;
33using log4net; 32using log4net;
34using Mono.Addins; 33using Mono.Addins;
35using Nini.Config; 34using Nini.Config;
36using OpenSim.Framework; 35using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
41using OpenSim.Server.Base;
42using OpenMetaverse; 39using OpenMetaverse;
43using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
44 41
@@ -59,6 +56,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
59 56
60 private string m_serverUrl = String.Empty; 57 private string m_serverUrl = String.Empty;
61 private SimianActivityDetector m_activityDetector; 58 private SimianActivityDetector m_activityDetector;
59 private bool m_Enabled = false;
62 60
63 #region ISharedRegionModule 61 #region ISharedRegionModule
64 62
@@ -71,7 +69,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
71 public string Name { get { return "SimianPresenceServiceConnector"; } } 69 public string Name { get { return "SimianPresenceServiceConnector"; } }
72 public void AddRegion(Scene scene) 70 public void AddRegion(Scene scene)
73 { 71 {
74 if (!String.IsNullOrEmpty(m_serverUrl)) 72 if (m_Enabled)
75 { 73 {
76 scene.RegisterModuleInterface<IPresenceService>(this); 74 scene.RegisterModuleInterface<IPresenceService>(this);
77 scene.RegisterModuleInterface<IGridUserService>(this); 75 scene.RegisterModuleInterface<IGridUserService>(this);
@@ -83,7 +81,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
83 } 81 }
84 public void RemoveRegion(Scene scene) 82 public void RemoveRegion(Scene scene)
85 { 83 {
86 if (!String.IsNullOrEmpty(m_serverUrl)) 84 if (m_Enabled)
87 { 85 {
88 scene.UnregisterModuleInterface<IPresenceService>(this); 86 scene.UnregisterModuleInterface<IPresenceService>(this);
89 scene.UnregisterModuleInterface<IGridUserService>(this); 87 scene.UnregisterModuleInterface<IGridUserService>(this);
@@ -98,11 +96,22 @@ namespace OpenSim.Services.Connectors.SimianGrid
98 96
99 public SimianPresenceServiceConnector(IConfigSource source) 97 public SimianPresenceServiceConnector(IConfigSource source)
100 { 98 {
101 Initialise(source); 99 CommonInit(source);
102 } 100 }
103 101
104 public void Initialise(IConfigSource source) 102 public void Initialise(IConfigSource source)
105 { 103 {
104 IConfig moduleConfig = source.Configs["Modules"];
105 if (moduleConfig != null)
106 {
107 string name = moduleConfig.GetString("PresenceServices", "");
108 if (name == Name)
109 CommonInit(source);
110 }
111 }
112
113 private void CommonInit(IConfigSource source)
114 {
106 IConfig gridConfig = source.Configs["PresenceService"]; 115 IConfig gridConfig = source.Configs["PresenceService"];
107 if (gridConfig != null) 116 if (gridConfig != null)
108 { 117 {
@@ -112,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
112 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
113 serviceUrl = serviceUrl + '/'; 122 serviceUrl = serviceUrl + '/';
114 m_serverUrl = serviceUrl; 123 m_serverUrl = serviceUrl;
124 m_Enabled = true;
115 } 125 }
116 } 126 }
117 127
@@ -345,25 +355,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
345 return null; 355 return null;
346 } 356 }
347 357
348// private OSDMap GetSessionData(UUID sessionID)
349// {
350// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for session " + sessionID);
351//
352// NameValueCollection requestArgs = new NameValueCollection
353// {
354// { "RequestMethod", "GetSession" },
355// { "SessionID", sessionID.ToString() }
356// };
357//
358// OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
359// if (response["Success"].AsBoolean())
360// return response;
361// else
362// m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for session " + sessionID);
363//
364// return null;
365// }
366
367 private List<PresenceInfo> GetSessions(UUID userID) 358 private List<PresenceInfo> GetSessions(UUID userID)
368 { 359 {
369 List<PresenceInfo> presences = new List<PresenceInfo>(1); 360 List<PresenceInfo> presences = new List<PresenceInfo>(1);
@@ -416,39 +407,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
416 return success; 407 return success;
417 } 408 }
418 409
419 ///// <summary>
420 ///// Fetch the last known avatar location with GetSession and persist it
421 ///// as user data with AddUserData
422 ///// </summary>
423 //private bool SetLastLocation(UUID sessionID)
424 //{
425 // NameValueCollection requestArgs = new NameValueCollection
426 // {
427 // { "RequestMethod", "GetSession" },
428 // { "SessionID", sessionID.ToString() }
429 // };
430
431 // OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
432 // bool success = response["Success"].AsBoolean();
433
434 // if (success)
435 // {
436 // UUID userID = response["UserID"].AsUUID();
437 // UUID sceneID = response["SceneID"].AsUUID();
438 // Vector3 position = response["ScenePosition"].AsVector3();
439 // Vector3 lookAt = response["SceneLookAt"].AsVector3();
440
441 // return SetLastLocation(userID, sceneID, position, lookAt);
442 // }
443 // else
444 // {
445 // m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve presence information for session " + sessionID +
446 // " while saving last location: " + response["Message"].AsString());
447 // }
448
449 // return success;
450 //}
451
452 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) 410 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse)
453 { 411 {
454 if (sessionResponse == null) 412 if (sessionResponse == null)
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
index a817d7c..b7e8538 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs
@@ -67,6 +67,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
67 MethodBase.GetCurrentMethod().DeclaringType); 67 MethodBase.GetCurrentMethod().DeclaringType);
68 68
69 private string m_serverUrl = String.Empty; 69 private string m_serverUrl = String.Empty;
70 private bool m_Enabled = false;
70 71
71 #region INonSharedRegionModule 72 #region INonSharedRegionModule
72 73
@@ -76,8 +77,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
76 77
77 public SimianProfiles() { } 78 public SimianProfiles() { }
78 public string Name { get { return "SimianProfiles"; } } 79 public string Name { get { return "SimianProfiles"; } }
79 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { CheckEstateManager(scene); scene.EventManager.OnClientConnect += ClientConnectHandler; } } 80 public void AddRegion(Scene scene) { if (m_Enabled) { CheckEstateManager(scene); scene.EventManager.OnClientConnect += ClientConnectHandler; } }
80 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.EventManager.OnClientConnect -= ClientConnectHandler; } } 81 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.EventManager.OnClientConnect -= ClientConnectHandler; } }
81 82
82 #endregion INonSharedRegionModule 83 #endregion INonSharedRegionModule
83 84
@@ -88,6 +89,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
88 89
89 public void Initialise(IConfigSource source) 90 public void Initialise(IConfigSource source)
90 { 91 {
92 IConfig profileConfig = source.Configs["Profile"];
93 if (profileConfig == null)
94 return;
95
96 if (profileConfig.GetString("Module", String.Empty) != Name)
97 return;
98
91 IConfig gridConfig = source.Configs["UserAccountService"]; 99 IConfig gridConfig = source.Configs["UserAccountService"];
92 if (gridConfig != null) 100 if (gridConfig != null)
93 { 101 {
@@ -283,8 +291,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
283 // Check if the user is online 291 // Check if the user is online
284 if (client.Scene is Scene) 292 if (client.Scene is Scene)
285 { 293 {
286 OpenSim.Services.Interfaces.PresenceInfo[] presences = ((Scene)client.Scene).PresenceService.GetAgents(new string[] { avatarID.ToString() }); 294 OpenSim.Services.Interfaces.PresenceInfo presence = ((Scene)client.Scene).PresenceService.GetAgent(avatarID);
287 if (presences != null && presences.Length > 0) 295 if (presence != null)
288 flags |= ProfileFlags.Online; 296 flags |= ProfileFlags.Online;
289 } 297 }
290 298
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 4c8662f..ddd2322 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.IO;
32using System.Reflection; 31using System.Reflection;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
@@ -49,12 +48,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
50 public class SimianUserAccountServiceConnector : IUserAccountService, ISharedRegionModule 49 public class SimianUserAccountServiceConnector : IUserAccountService, ISharedRegionModule
51 { 50 {
51 private const double CACHE_EXPIRATION_SECONDS = 120.0;
52
52 private static readonly ILog m_log = 53 private static readonly ILog m_log =
53 LogManager.GetLogger( 54 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
55 56
56 private string m_serverUrl = String.Empty; 57 private string m_serverUrl = String.Empty;
57 private ExpiringCache<UUID, UserAccount> m_accountCache; 58 private ExpiringCache<UUID, UserAccount> m_accountCache = new ExpiringCache<UUID,UserAccount>();
59 private bool m_Enabled;
58 60
59 #region ISharedRegionModule 61 #region ISharedRegionModule
60 62
@@ -65,18 +67,29 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 67
66 public SimianUserAccountServiceConnector() { } 68 public SimianUserAccountServiceConnector() { }
67 public string Name { get { return "SimianUserAccountServiceConnector"; } } 69 public string Name { get { return "SimianUserAccountServiceConnector"; } }
68 public void AddRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface<IUserAccountService>(this); } } 70 public void AddRegion(Scene scene) { if (m_Enabled) { scene.RegisterModuleInterface<IUserAccountService>(this); } }
69 public void RemoveRegion(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface<IUserAccountService>(this); } } 71 public void RemoveRegion(Scene scene) { if (m_Enabled) { scene.UnregisterModuleInterface<IUserAccountService>(this); } }
70 72
71 #endregion ISharedRegionModule 73 #endregion ISharedRegionModule
72 74
73 public SimianUserAccountServiceConnector(IConfigSource source) 75 public SimianUserAccountServiceConnector(IConfigSource source)
74 { 76 {
75 Initialise(source); 77 CommonInit(source);
76 } 78 }
77 79
78 public void Initialise(IConfigSource source) 80 public void Initialise(IConfigSource source)
79 { 81 {
82 IConfig moduleConfig = source.Configs["Modules"];
83 if (moduleConfig != null)
84 {
85 string name = moduleConfig.GetString("UserAccountServices", "");
86 if (name == Name)
87 CommonInit(source);
88 }
89 }
90
91 private void CommonInit(IConfigSource source)
92 {
80 IConfig gridConfig = source.Configs["UserAccountService"]; 93 IConfig gridConfig = source.Configs["UserAccountService"];
81 if (gridConfig != null) 94 if (gridConfig != null)
82 { 95 {
@@ -86,6 +99,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
86 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 99 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
87 serviceUrl = serviceUrl + '/'; 100 serviceUrl = serviceUrl + '/';
88 m_serverUrl = serviceUrl; 101 m_serverUrl = serviceUrl;
102 m_Enabled = true;
89 } 103 }
90 } 104 }
91 105
@@ -128,7 +142,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
128 { "UserID", userID.ToString() } 142 { "UserID", userID.ToString() }
129 }; 143 };
130 144
131 return GetUser(requestArgs); 145 account = GetUser(requestArgs);
146
147 if (account == null)
148 {
149 // Store null responses too, to avoid repeated lookups for missing accounts
150 m_accountCache.AddOrUpdate(userID, null, DateTime.Now + TimeSpan.FromSeconds(CACHE_EXPIRATION_SECONDS));
151 }
152
153 return account;
132 } 154 }
133 155
134 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 156 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
@@ -203,7 +225,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
203 if (success) 225 if (success)
204 { 226 {
205 // Cache the user account info 227 // Cache the user account info
206 m_accountCache.AddOrUpdate(data.PrincipalID, data, DateTime.Now + TimeSpan.FromMinutes(2.0d)); 228 m_accountCache.AddOrUpdate(data.PrincipalID, data, DateTime.Now + TimeSpan.FromSeconds(CACHE_EXPIRATION_SECONDS));
207 } 229 }
208 else 230 else
209 { 231 {
@@ -268,7 +290,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
268 GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName); 290 GetFirstLastName(response["Name"].AsString(), out account.FirstName, out account.LastName);
269 291
270 // Cache the user account info 292 // Cache the user account info
271 m_accountCache.AddOrUpdate(account.PrincipalID, account, DateTime.Now + TimeSpan.FromMinutes(2.0d)); 293 m_accountCache.AddOrUpdate(account.PrincipalID, account, DateTime.Now + TimeSpan.FromSeconds(CACHE_EXPIRATION_SECONDS));
272 294
273 return account; 295 return account;
274 } 296 }