aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2009-03-31 02:00:33 +0000
committerJeff Ames2009-03-31 02:00:33 +0000
commit54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b (patch)
treef0bf3e10df71075f7a3d9552578679fe0cfdd477 /OpenSim
parentCommitting the changed binaries to get jhurliman's patch into our repo (diff)
downloadopensim-SC_OLD-54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b.zip
opensim-SC_OLD-54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b.tar.gz
opensim-SC_OLD-54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b.tar.bz2
opensim-SC_OLD-54ccca1e2cb8af5d0fdc420f64574a7d7b13c94b.tar.xz
Update svn properties, add copyright header, formatting cleanup.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs2
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs4
-rw-r--r--OpenSim/Framework/Communications/IAuthentication.cs51
-rw-r--r--OpenSim/Framework/Communications/Services/GridInfoService.cs344
-rw-r--r--OpenSim/Framework/Communications/Services/LoginResponse.cs1624
-rw-r--r--OpenSim/Framework/Communications/Services/LoginService.cs2186
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs448
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs330
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs506
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs64
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs56
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs1
13 files changed, 2819 insertions, 2799 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
index 5ff9da3..180d6f4 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs
@@ -227,7 +227,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
227 // them easy to reach from anywhere in the assembly. 227 // them easy to reach from anywhere in the assembly.
228 228
229 Rest.main = openSim; 229 Rest.main = openSim;
230 if(Rest.main == null) 230 if (Rest.main == null)
231 throw new Exception("OpenSim base pointer is null"); 231 throw new Exception("OpenSim base pointer is null");
232 232
233 Rest.Plugin = this; 233 Rest.Plugin = this;
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index d79645e..73aa6ba 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -503,7 +503,7 @@ namespace OpenSim.Framework.Communications.Cache
503 req.Params = transferRequest.TransferInfo.Params; 503 req.Params = transferRequest.TransferInfo.Params;
504 req.AssetInf = new AssetInfo(asset); 504 req.AssetInf = new AssetInfo(asset);
505 req.NumPackets = CalculateNumPackets(asset.Data); 505 req.NumPackets = CalculateNumPackets(asset.Data);
506 lock(AssetRequests) AssetRequests.Add(req); 506 lock (AssetRequests) AssetRequests.Add(req);
507 } 507 }
508 508
509 /// <summary> 509 /// <summary>
@@ -526,7 +526,7 @@ namespace OpenSim.Framework.Communications.Cache
526 526
527 for (int i = 0; i < num; i++) 527 for (int i = 0; i < num; i++)
528 { 528 {
529 lock(AssetRequests) 529 lock (AssetRequests)
530 { 530 {
531 req = AssetRequests[0]; 531 req = AssetRequests[0];
532 AssetRequests.RemoveAt(0); 532 AssetRequests.RemoveAt(0);
diff --git a/OpenSim/Framework/Communications/IAuthentication.cs b/OpenSim/Framework/Communications/IAuthentication.cs
index 5d6d5f2..0f62569 100644
--- a/OpenSim/Framework/Communications/IAuthentication.cs
+++ b/OpenSim/Framework/Communications/IAuthentication.cs
@@ -1,13 +1,38 @@
1using System; 1/*
2 2 * Copyright (c) Contributors, http://opensimulator.org/
3using OpenMetaverse; 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 4 *
5 5 * Redistribution and use in source and binary forms, with or without
6namespace OpenSim.Framework.Communications 6 * modification, are permitted provided that the following conditions are met:
7{ 7 * * Redistributions of source code must retain the above copyright
8 public interface IAuthentication 8 * notice, this list of conditions and the following disclaimer.
9 { 9 * * Redistributions in binary form must reproduce the above copyright
10 string GetNewKey(string url, UUID userID, UUID authToken); 10 * notice, this list of conditions and the following disclaimer in the
11 bool VerifyKey(UUID userID, string key); 11 * documentation and/or other materials provided with the distribution.
12 } 12 * * Neither the name of the OpenSimulator Project nor the
13} 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 OpenMetaverse;
30
31namespace OpenSim.Framework.Communications
32{
33 public interface IAuthentication
34 {
35 string GetNewKey(string url, UUID userID, UUID authToken);
36 bool VerifyKey(UUID userID, string key);
37 }
38}
diff --git a/OpenSim/Framework/Communications/Services/GridInfoService.cs b/OpenSim/Framework/Communications/Services/GridInfoService.cs
index 96fe0d8..030ea61 100644
--- a/OpenSim/Framework/Communications/Services/GridInfoService.cs
+++ b/OpenSim/Framework/Communications/Services/GridInfoService.cs
@@ -1,172 +1,172 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using log4net; 33using log4net;
34using Nini.Config; 34using Nini.Config;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37 37
38namespace OpenSim.Framework.Communications.Services 38namespace OpenSim.Framework.Communications.Services
39{ 39{
40 public class GridInfoService 40 public class GridInfoService
41 { 41 {
42 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private Hashtable _info = new Hashtable(); 44 private Hashtable _info = new Hashtable();
45 45
46 /// <summary> 46 /// <summary>
47 /// Instantiate a GridInfoService object. 47 /// Instantiate a GridInfoService object.
48 /// </summary> 48 /// </summary>
49 /// <param name="configPath">path to config path containing 49 /// <param name="configPath">path to config path containing
50 /// grid information</param> 50 /// grid information</param>
51 /// <remarks> 51 /// <remarks>
52 /// GridInfoService uses the [GridInfo] section of the 52 /// GridInfoService uses the [GridInfo] section of the
53 /// standard OpenSim.ini file --- which is not optimal, but 53 /// standard OpenSim.ini file --- which is not optimal, but
54 /// anything else requires a general redesign of the config 54 /// anything else requires a general redesign of the config
55 /// system. 55 /// system.
56 /// </remarks> 56 /// </remarks>
57 public GridInfoService(IConfigSource configSource) 57 public GridInfoService(IConfigSource configSource)
58 { 58 {
59 loadGridInfo(configSource); 59 loadGridInfo(configSource);
60 } 60 }
61 61
62 /// <summary> 62 /// <summary>
63 /// Default constructor, uses OpenSim.ini. 63 /// Default constructor, uses OpenSim.ini.
64 /// </summary> 64 /// </summary>
65 public GridInfoService() 65 public GridInfoService()
66 { 66 {
67 try 67 try
68 { 68 {
69 IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini")); 69 IConfigSource configSource = new IniConfigSource(Path.Combine(Util.configDir(), "OpenSim.ini"));
70 loadGridInfo(configSource); 70 loadGridInfo(configSource);
71 } 71 }
72 catch (FileNotFoundException) 72 catch (FileNotFoundException)
73 { 73 {
74 _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users"); 74 _log.Warn("[GridInfoService] no OpenSim.ini file found --- GridInfoServices WILL NOT BE AVAILABLE to your users");
75 } 75 }
76 } 76 }
77 77
78 private void loadGridInfo(IConfigSource configSource) 78 private void loadGridInfo(IConfigSource configSource)
79 { 79 {
80 _info["platform"] = "OpenSim"; 80 _info["platform"] = "OpenSim";
81 try 81 try
82 { 82 {
83 IConfig startupCfg = configSource.Configs["Startup"]; 83 IConfig startupCfg = configSource.Configs["Startup"];
84 IConfig gridCfg = configSource.Configs["GridInfo"]; 84 IConfig gridCfg = configSource.Configs["GridInfo"];
85 IConfig netCfg = configSource.Configs["Network"]; 85 IConfig netCfg = configSource.Configs["Network"];
86 86
87 bool grid = startupCfg.GetBoolean("gridmode", false); 87 bool grid = startupCfg.GetBoolean("gridmode", false);
88 88
89 if (grid) 89 if (grid)
90 _info["mode"] = "grid"; 90 _info["mode"] = "grid";
91 else 91 else
92 _info["mode"] = "standalone"; 92 _info["mode"] = "standalone";
93 93
94 94
95 if (null != gridCfg) 95 if (null != gridCfg)
96 { 96 {
97 foreach (string k in gridCfg.GetKeys()) 97 foreach (string k in gridCfg.GetKeys())
98 { 98 {
99 _info[k] = gridCfg.GetString(k); 99 _info[k] = gridCfg.GetString(k);
100 } 100 }
101 } 101 }
102 else if (null != netCfg) 102 else if (null != netCfg)
103 { 103 {
104 if (grid) 104 if (grid)
105 _info["login"] 105 _info["login"]
106 = netCfg.GetString( 106 = netCfg.GetString(
107 "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); 107 "user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
108 else 108 else
109 _info["login"] 109 _info["login"]
110 = String.Format( 110 = String.Format(
111 "http://127.0.0.1:{0}/", 111 "http://127.0.0.1:{0}/",
112 netCfg.GetString( 112 netCfg.GetString(
113 "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString())); 113 "http_listener_port", NetworkServersInfo.DefaultHttpListenerPort.ToString()));
114 114
115 IssueWarning(); 115 IssueWarning();
116 } 116 }
117 else 117 else
118 { 118 {
119 _info["login"] = "http://127.0.0.1:9000/"; 119 _info["login"] = "http://127.0.0.1:9000/";
120 IssueWarning(); 120 IssueWarning();
121 } 121 }
122 } 122 }
123 catch (Exception) 123 catch (Exception)
124 { 124 {
125 _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults"); 125 _log.Debug("[GridInfoService] cannot get grid info from config source, using minimal defaults");
126 } 126 }
127 _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count); 127 _log.InfoFormat("[GridInfoService] Grid info service initialized with {0} keys", _info.Count);
128 128
129 } 129 }
130 130
131 private void IssueWarning() 131 private void IssueWarning()
132 { 132 {
133 _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini"); 133 _log.Warn("[GridInfoService] found no [GridInfo] section in your OpenSim.ini");
134 _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:"); 134 _log.Warn("[GridInfoService] trying to guess sensible defaults, you might want to provide better ones:");
135 foreach (string k in _info.Keys) 135 foreach (string k in _info.Keys)
136 { 136 {
137 _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]); 137 _log.WarnFormat("[GridInfoService] {0}: {1}", k, _info[k]);
138 } 138 }
139 } 139 }
140 140
141 public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request) 141 public XmlRpcResponse XmlRpcGridInfoMethod(XmlRpcRequest request)
142 { 142 {
143 XmlRpcResponse response = new XmlRpcResponse(); 143 XmlRpcResponse response = new XmlRpcResponse();
144 Hashtable responseData = new Hashtable(); 144 Hashtable responseData = new Hashtable();
145 145
146 _log.Info("[GridInfo]: Request for grid info"); 146 _log.Info("[GridInfo]: Request for grid info");
147 147
148 foreach (string k in _info.Keys) 148 foreach (string k in _info.Keys)
149 { 149 {
150 responseData[k] = _info[k]; 150 responseData[k] = _info[k];
151 } 151 }
152 response.Value = responseData; 152 response.Value = responseData;
153 153
154 return response; 154 return response;
155 } 155 }
156 156
157 public string RestGetGridInfoMethod(string request, string path, string param, 157 public string RestGetGridInfoMethod(string request, string path, string param,
158 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 158 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
159 { 159 {
160 StringBuilder sb = new StringBuilder(); 160 StringBuilder sb = new StringBuilder();
161 161
162 sb.Append("<gridinfo>\n"); 162 sb.Append("<gridinfo>\n");
163 foreach (string k in _info.Keys) 163 foreach (string k in _info.Keys)
164 { 164 {
165 sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]); 165 sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]);
166 } 166 }
167 sb.Append("</gridinfo>\n"); 167 sb.Append("</gridinfo>\n");
168 168
169 return sb.ToString(); 169 return sb.ToString();
170 } 170 }
171 } 171 }
172} 172}
diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Framework/Communications/Services/LoginResponse.cs
index 82515e0..db208a4 100644
--- a/OpenSim/Framework/Communications/Services/LoginResponse.cs
+++ b/OpenSim/Framework/Communications/Services/LoginResponse.cs
@@ -1,812 +1,812 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
36 36
37namespace OpenSim.Framework.Communications.Services 37namespace OpenSim.Framework.Communications.Services
38{ 38{
39 /// <summary> 39 /// <summary>
40 /// A temp class to handle login response. 40 /// A temp class to handle login response.
41 /// Should make use of UserProfileManager where possible. 41 /// Should make use of UserProfileManager where possible.
42 /// </summary> 42 /// </summary>
43 public class LoginResponse 43 public class LoginResponse
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private Hashtable loginFlagsHash; 47 private Hashtable loginFlagsHash;
48 private Hashtable globalTexturesHash; 48 private Hashtable globalTexturesHash;
49 private Hashtable loginError; 49 private Hashtable loginError;
50 private Hashtable uiConfigHash; 50 private Hashtable uiConfigHash;
51 51
52 private ArrayList loginFlags; 52 private ArrayList loginFlags;
53 private ArrayList globalTextures; 53 private ArrayList globalTextures;
54 private ArrayList eventCategories; 54 private ArrayList eventCategories;
55 private ArrayList uiConfig; 55 private ArrayList uiConfig;
56 private ArrayList classifiedCategories; 56 private ArrayList classifiedCategories;
57 private ArrayList inventoryRoot; 57 private ArrayList inventoryRoot;
58 private ArrayList initialOutfit; 58 private ArrayList initialOutfit;
59 private ArrayList agentInventory; 59 private ArrayList agentInventory;
60 private ArrayList inventoryLibraryOwner; 60 private ArrayList inventoryLibraryOwner;
61 private ArrayList inventoryLibRoot; 61 private ArrayList inventoryLibRoot;
62 private ArrayList inventoryLibrary; 62 private ArrayList inventoryLibrary;
63 private ArrayList activeGestures; 63 private ArrayList activeGestures;
64 64
65 private UserInfo userProfile; 65 private UserInfo userProfile;
66 66
67 private UUID agentID; 67 private UUID agentID;
68 private UUID sessionID; 68 private UUID sessionID;
69 private UUID secureSessionID; 69 private UUID secureSessionID;
70 70
71 // Login Flags 71 // Login Flags
72 private string dst; 72 private string dst;
73 private string stipendSinceLogin; 73 private string stipendSinceLogin;
74 private string gendered; 74 private string gendered;
75 private string everLoggedIn; 75 private string everLoggedIn;
76 private string login; 76 private string login;
77 private uint simPort; 77 private uint simPort;
78 private uint simHttpPort; 78 private uint simHttpPort;
79 private string simAddress; 79 private string simAddress;
80 private string agentAccess; 80 private string agentAccess;
81 private Int32 circuitCode; 81 private Int32 circuitCode;
82 private uint regionX; 82 private uint regionX;
83 private uint regionY; 83 private uint regionY;
84 84
85 // Login 85 // Login
86 private string firstname; 86 private string firstname;
87 private string lastname; 87 private string lastname;
88 88
89 // Global Textures 89 // Global Textures
90 private string sunTexture; 90 private string sunTexture;
91 private string cloudTexture; 91 private string cloudTexture;
92 private string moonTexture; 92 private string moonTexture;
93 93
94 // Error Flags 94 // Error Flags
95 private string errorReason; 95 private string errorReason;
96 private string errorMessage; 96 private string errorMessage;
97 97
98 // Response 98 // Response
99 private XmlRpcResponse xmlRpcResponse; 99 private XmlRpcResponse xmlRpcResponse;
100 // private XmlRpcResponse defaultXmlRpcResponse; 100 // private XmlRpcResponse defaultXmlRpcResponse;
101 101
102 private string welcomeMessage; 102 private string welcomeMessage;
103 private string startLocation; 103 private string startLocation;
104 private string allowFirstLife; 104 private string allowFirstLife;
105 private string home; 105 private string home;
106 private string seedCapability; 106 private string seedCapability;
107 private string lookAt; 107 private string lookAt;
108 108
109 private BuddyList m_buddyList = null; 109 private BuddyList m_buddyList = null;
110 110
111 public LoginResponse() 111 public LoginResponse()
112 { 112 {
113 loginFlags = new ArrayList(); 113 loginFlags = new ArrayList();
114 globalTextures = new ArrayList(); 114 globalTextures = new ArrayList();
115 eventCategories = new ArrayList(); 115 eventCategories = new ArrayList();
116 uiConfig = new ArrayList(); 116 uiConfig = new ArrayList();
117 classifiedCategories = new ArrayList(); 117 classifiedCategories = new ArrayList();
118 118
119 loginError = new Hashtable(); 119 loginError = new Hashtable();
120 uiConfigHash = new Hashtable(); 120 uiConfigHash = new Hashtable();
121 121
122 // defaultXmlRpcResponse = new XmlRpcResponse(); 122 // defaultXmlRpcResponse = new XmlRpcResponse();
123 userProfile = new UserInfo(); 123 userProfile = new UserInfo();
124 inventoryRoot = new ArrayList(); 124 inventoryRoot = new ArrayList();
125 initialOutfit = new ArrayList(); 125 initialOutfit = new ArrayList();
126 agentInventory = new ArrayList(); 126 agentInventory = new ArrayList();
127 inventoryLibrary = new ArrayList(); 127 inventoryLibrary = new ArrayList();
128 inventoryLibraryOwner = new ArrayList(); 128 inventoryLibraryOwner = new ArrayList();
129 activeGestures = new ArrayList(); 129 activeGestures = new ArrayList();
130 130
131 xmlRpcResponse = new XmlRpcResponse(); 131 xmlRpcResponse = new XmlRpcResponse();
132 // defaultXmlRpcResponse = new XmlRpcResponse(); 132 // defaultXmlRpcResponse = new XmlRpcResponse();
133 133
134 SetDefaultValues(); 134 SetDefaultValues();
135 } 135 }
136 136
137 private void SetDefaultValues() 137 private void SetDefaultValues()
138 { 138 {
139 DST = "N"; 139 DST = "N";
140 StipendSinceLogin = "N"; 140 StipendSinceLogin = "N";
141 Gendered = "Y"; 141 Gendered = "Y";
142 EverLoggedIn = "Y"; 142 EverLoggedIn = "Y";
143 login = "false"; 143 login = "false";
144 firstname = "Test"; 144 firstname = "Test";
145 lastname = "User"; 145 lastname = "User";
146 agentAccess = "M"; 146 agentAccess = "M";
147 startLocation = "last"; 147 startLocation = "last";
148 allowFirstLife = "Y"; 148 allowFirstLife = "Y";
149 149
150 SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; 150 SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
151 CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; 151 CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
152 MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; 152 MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
153 153
154 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; 154 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
155 ErrorReason = "key"; 155 ErrorReason = "key";
156 welcomeMessage = "Welcome to OpenSim!"; 156 welcomeMessage = "Welcome to OpenSim!";
157 seedCapability = String.Empty; 157 seedCapability = String.Empty;
158 home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + 158 home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" +
159 userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + 159 userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
160 userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + 160 userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
161 userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; 161 userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
162 lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; 162 lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
163 RegionX = (uint) 255232; 163 RegionX = (uint) 255232;
164 RegionY = (uint) 254976; 164 RegionY = (uint) 254976;
165 165
166 // Classifieds; 166 // Classifieds;
167 AddClassifiedCategory((Int32) 1, "Shopping"); 167 AddClassifiedCategory((Int32) 1, "Shopping");
168 AddClassifiedCategory((Int32) 2, "Land Rental"); 168 AddClassifiedCategory((Int32) 2, "Land Rental");
169 AddClassifiedCategory((Int32) 3, "Property Rental"); 169 AddClassifiedCategory((Int32) 3, "Property Rental");
170 AddClassifiedCategory((Int32) 4, "Special Attraction"); 170 AddClassifiedCategory((Int32) 4, "Special Attraction");
171 AddClassifiedCategory((Int32) 5, "New Products"); 171 AddClassifiedCategory((Int32) 5, "New Products");
172 AddClassifiedCategory((Int32) 6, "Employment"); 172 AddClassifiedCategory((Int32) 6, "Employment");
173 AddClassifiedCategory((Int32) 7, "Wanted"); 173 AddClassifiedCategory((Int32) 7, "Wanted");
174 AddClassifiedCategory((Int32) 8, "Service"); 174 AddClassifiedCategory((Int32) 8, "Service");
175 AddClassifiedCategory((Int32) 9, "Personal"); 175 AddClassifiedCategory((Int32) 9, "Personal");
176 176
177 SessionID = UUID.Random(); 177 SessionID = UUID.Random();
178 SecureSessionID = UUID.Random(); 178 SecureSessionID = UUID.Random();
179 AgentID = UUID.Random(); 179 AgentID = UUID.Random();
180 180
181 Hashtable InitialOutfitHash = new Hashtable(); 181 Hashtable InitialOutfitHash = new Hashtable();
182 InitialOutfitHash["folder_name"] = "Nightclub Female"; 182 InitialOutfitHash["folder_name"] = "Nightclub Female";
183 InitialOutfitHash["gender"] = "female"; 183 InitialOutfitHash["gender"] = "female";
184 initialOutfit.Add(InitialOutfitHash); 184 initialOutfit.Add(InitialOutfitHash);
185 } 185 }
186 186
187 #region Login Failure Methods 187 #region Login Failure Methods
188 188
189 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) 189 public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
190 { 190 {
191 // Overwrite any default values; 191 // Overwrite any default values;
192 xmlRpcResponse = new XmlRpcResponse(); 192 xmlRpcResponse = new XmlRpcResponse();
193 193
194 // Ensure Login Failed message/reason; 194 // Ensure Login Failed message/reason;
195 ErrorMessage = message; 195 ErrorMessage = message;
196 ErrorReason = reason; 196 ErrorReason = reason;
197 197
198 loginError["reason"] = ErrorReason; 198 loginError["reason"] = ErrorReason;
199 loginError["message"] = ErrorMessage; 199 loginError["message"] = ErrorMessage;
200 loginError["login"] = login; 200 loginError["login"] = login;
201 xmlRpcResponse.Value = loginError; 201 xmlRpcResponse.Value = loginError;
202 return (xmlRpcResponse); 202 return (xmlRpcResponse);
203 } 203 }
204 204
205 public OSD GenerateFailureResponseLLSD(string reason, string message, string login) 205 public OSD GenerateFailureResponseLLSD(string reason, string message, string login)
206 { 206 {
207 OSDMap map = new OSDMap(); 207 OSDMap map = new OSDMap();
208 208
209 // Ensure Login Failed message/reason; 209 // Ensure Login Failed message/reason;
210 ErrorMessage = message; 210 ErrorMessage = message;
211 ErrorReason = reason; 211 ErrorReason = reason;
212 212
213 map["reason"] = OSD.FromString(ErrorReason); 213 map["reason"] = OSD.FromString(ErrorReason);
214 map["message"] = OSD.FromString(ErrorMessage); 214 map["message"] = OSD.FromString(ErrorMessage);
215 map["login"] = OSD.FromString(login); 215 map["login"] = OSD.FromString(login);
216 216
217 return map; 217 return map;
218 } 218 }
219 219
220 public XmlRpcResponse CreateFailedResponse() 220 public XmlRpcResponse CreateFailedResponse()
221 { 221 {
222 return (CreateLoginFailedResponse()); 222 return (CreateLoginFailedResponse());
223 } 223 }
224 224
225 public OSD CreateFailedResponseLLSD() 225 public OSD CreateFailedResponseLLSD()
226 { 226 {
227 return CreateLoginFailedResponseLLSD(); 227 return CreateLoginFailedResponseLLSD();
228 } 228 }
229 229
230 public XmlRpcResponse CreateLoginFailedResponse() 230 public XmlRpcResponse CreateLoginFailedResponse()
231 { 231 {
232 return 232 return
233 (GenerateFailureResponse("key", 233 (GenerateFailureResponse("key",
234 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", 234 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
235 "false")); 235 "false"));
236 } 236 }
237 237
238 public OSD CreateLoginFailedResponseLLSD() 238 public OSD CreateLoginFailedResponseLLSD()
239 { 239 {
240 return GenerateFailureResponseLLSD( 240 return GenerateFailureResponseLLSD(
241 "key", 241 "key",
242 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", 242 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
243 "false"); 243 "false");
244 } 244 }
245 245
246 /// <summary> 246 /// <summary>
247 /// Response to indicate that login failed because the agent's inventory was not available. 247 /// Response to indicate that login failed because the agent's inventory was not available.
248 /// </summary> 248 /// </summary>
249 /// <returns></returns> 249 /// <returns></returns>
250 public XmlRpcResponse CreateLoginInventoryFailedResponse() 250 public XmlRpcResponse CreateLoginInventoryFailedResponse()
251 { 251 {
252 return GenerateFailureResponse( 252 return GenerateFailureResponse(
253 "key", 253 "key",
254 "The avatar inventory service is not responding. Please notify your login region operator.", 254 "The avatar inventory service is not responding. Please notify your login region operator.",
255 "false"); 255 "false");
256 } 256 }
257 257
258 public XmlRpcResponse CreateAlreadyLoggedInResponse() 258 public XmlRpcResponse CreateAlreadyLoggedInResponse()
259 { 259 {
260 return 260 return
261 (GenerateFailureResponse("presence", 261 (GenerateFailureResponse("presence",
262 "You appear to be already logged in. " + 262 "You appear to be already logged in. " +
263 "If this is not the case please wait for your session to timeout. " + 263 "If this is not the case please wait for your session to timeout. " +
264 "If this takes longer than a few minutes please contact the grid owner. " + 264 "If this takes longer than a few minutes please contact the grid owner. " +
265 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", 265 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
266 "false")); 266 "false"));
267 } 267 }
268 268
269 public OSD CreateAlreadyLoggedInResponseLLSD() 269 public OSD CreateAlreadyLoggedInResponseLLSD()
270 { 270 {
271 return GenerateFailureResponseLLSD( 271 return GenerateFailureResponseLLSD(
272 "presence", 272 "presence",
273 "You appear to be already logged in. " + 273 "You appear to be already logged in. " +
274 "If this is not the case please wait for your session to timeout. " + 274 "If this is not the case please wait for your session to timeout. " +
275 "If this takes longer than a few minutes please contact the grid owner", 275 "If this takes longer than a few minutes please contact the grid owner",
276 "false"); 276 "false");
277 } 277 }
278 278
279 public XmlRpcResponse CreateLoginBlockedResponse() 279 public XmlRpcResponse CreateLoginBlockedResponse()
280 { 280 {
281 return 281 return
282 (GenerateFailureResponse("presence", 282 (GenerateFailureResponse("presence",
283 "Logins are currently restricted. Please try again later", 283 "Logins are currently restricted. Please try again later",
284 "false")); 284 "false"));
285 } 285 }
286 286
287 public OSD CreateLoginBlockedResponseLLSD() 287 public OSD CreateLoginBlockedResponseLLSD()
288 { 288 {
289 return GenerateFailureResponseLLSD( 289 return GenerateFailureResponseLLSD(
290 "presence", 290 "presence",
291 "Logins are currently restricted. Please try again later", 291 "Logins are currently restricted. Please try again later",
292 "false"); 292 "false");
293 } 293 }
294 294
295 public XmlRpcResponse CreateDeadRegionResponse() 295 public XmlRpcResponse CreateDeadRegionResponse()
296 { 296 {
297 return 297 return
298 (GenerateFailureResponse("key", 298 (GenerateFailureResponse("key",
299 "The region you are attempting to log into is not responding. Please select another region and try again.", 299 "The region you are attempting to log into is not responding. Please select another region and try again.",
300 "false")); 300 "false"));
301 } 301 }
302 302
303 public OSD CreateDeadRegionResponseLLSD() 303 public OSD CreateDeadRegionResponseLLSD()
304 { 304 {
305 return GenerateFailureResponseLLSD( 305 return GenerateFailureResponseLLSD(
306 "key", 306 "key",
307 "The region you are attempting to log into is not responding. Please select another region and try again.", 307 "The region you are attempting to log into is not responding. Please select another region and try again.",
308 "false"); 308 "false");
309 } 309 }
310 310
311 public XmlRpcResponse CreateGridErrorResponse() 311 public XmlRpcResponse CreateGridErrorResponse()
312 { 312 {
313 return 313 return
314 (GenerateFailureResponse("key", 314 (GenerateFailureResponse("key",
315 "Error connecting to grid. Could not percieve credentials from login XML.", 315 "Error connecting to grid. Could not percieve credentials from login XML.",
316 "false")); 316 "false"));
317 } 317 }
318 318
319 public OSD CreateGridErrorResponseLLSD() 319 public OSD CreateGridErrorResponseLLSD()
320 { 320 {
321 return GenerateFailureResponseLLSD( 321 return GenerateFailureResponseLLSD(
322 "key", 322 "key",
323 "Error connecting to grid. Could not percieve credentials from login XML.", 323 "Error connecting to grid. Could not percieve credentials from login XML.",
324 "false"); 324 "false");
325 } 325 }
326 326
327 #endregion 327 #endregion
328 328
329 public virtual XmlRpcResponse ToXmlRpcResponse() 329 public virtual XmlRpcResponse ToXmlRpcResponse()
330 { 330 {
331 try 331 try
332 { 332 {
333 Hashtable responseData = new Hashtable(); 333 Hashtable responseData = new Hashtable();
334 334
335 loginFlagsHash = new Hashtable(); 335 loginFlagsHash = new Hashtable();
336 loginFlagsHash["daylight_savings"] = DST; 336 loginFlagsHash["daylight_savings"] = DST;
337 loginFlagsHash["stipend_since_login"] = StipendSinceLogin; 337 loginFlagsHash["stipend_since_login"] = StipendSinceLogin;
338 loginFlagsHash["gendered"] = Gendered; 338 loginFlagsHash["gendered"] = Gendered;
339 loginFlagsHash["ever_logged_in"] = EverLoggedIn; 339 loginFlagsHash["ever_logged_in"] = EverLoggedIn;
340 loginFlags.Add(loginFlagsHash); 340 loginFlags.Add(loginFlagsHash);
341 341
342 responseData["first_name"] = Firstname; 342 responseData["first_name"] = Firstname;
343 responseData["last_name"] = Lastname; 343 responseData["last_name"] = Lastname;
344 responseData["agent_access"] = agentAccess; 344 responseData["agent_access"] = agentAccess;
345 345
346 globalTexturesHash = new Hashtable(); 346 globalTexturesHash = new Hashtable();
347 globalTexturesHash["sun_texture_id"] = SunTexture; 347 globalTexturesHash["sun_texture_id"] = SunTexture;
348 globalTexturesHash["cloud_texture_id"] = CloudTexture; 348 globalTexturesHash["cloud_texture_id"] = CloudTexture;
349 globalTexturesHash["moon_texture_id"] = MoonTexture; 349 globalTexturesHash["moon_texture_id"] = MoonTexture;
350 globalTextures.Add(globalTexturesHash); 350 globalTextures.Add(globalTexturesHash);
351 // this.eventCategories.Add(this.eventCategoriesHash); 351 // this.eventCategories.Add(this.eventCategoriesHash);
352 352
353 AddToUIConfig("allow_first_life", allowFirstLife); 353 AddToUIConfig("allow_first_life", allowFirstLife);
354 uiConfig.Add(uiConfigHash); 354 uiConfig.Add(uiConfigHash);
355 355
356 responseData["sim_port"] = (Int32) SimPort; 356 responseData["sim_port"] = (Int32) SimPort;
357 responseData["sim_ip"] = SimAddress; 357 responseData["sim_ip"] = SimAddress;
358 responseData["http_port"] = (Int32)SimHttpPort; 358 responseData["http_port"] = (Int32)SimHttpPort;
359 359
360 responseData["agent_id"] = AgentID.ToString(); 360 responseData["agent_id"] = AgentID.ToString();
361 responseData["session_id"] = SessionID.ToString(); 361 responseData["session_id"] = SessionID.ToString();
362 responseData["secure_session_id"] = SecureSessionID.ToString(); 362 responseData["secure_session_id"] = SecureSessionID.ToString();
363 responseData["circuit_code"] = CircuitCode; 363 responseData["circuit_code"] = CircuitCode;
364 responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 364 responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
365 responseData["login-flags"] = loginFlags; 365 responseData["login-flags"] = loginFlags;
366 responseData["global-textures"] = globalTextures; 366 responseData["global-textures"] = globalTextures;
367 responseData["seed_capability"] = seedCapability; 367 responseData["seed_capability"] = seedCapability;
368 368
369 responseData["event_categories"] = eventCategories; 369 responseData["event_categories"] = eventCategories;
370 responseData["event_notifications"] = new ArrayList(); // todo 370 responseData["event_notifications"] = new ArrayList(); // todo
371 responseData["classified_categories"] = classifiedCategories; 371 responseData["classified_categories"] = classifiedCategories;
372 responseData["ui-config"] = uiConfig; 372 responseData["ui-config"] = uiConfig;
373 373
374 responseData["inventory-skeleton"] = agentInventory; 374 responseData["inventory-skeleton"] = agentInventory;
375 responseData["inventory-skel-lib"] = inventoryLibrary; 375 responseData["inventory-skel-lib"] = inventoryLibrary;
376 responseData["inventory-root"] = inventoryRoot; 376 responseData["inventory-root"] = inventoryRoot;
377 responseData["inventory-lib-root"] = inventoryLibRoot; 377 responseData["inventory-lib-root"] = inventoryLibRoot;
378 responseData["gestures"] = activeGestures; 378 responseData["gestures"] = activeGestures;
379 responseData["inventory-lib-owner"] = inventoryLibraryOwner; 379 responseData["inventory-lib-owner"] = inventoryLibraryOwner;
380 responseData["initial-outfit"] = initialOutfit; 380 responseData["initial-outfit"] = initialOutfit;
381 responseData["start_location"] = startLocation; 381 responseData["start_location"] = startLocation;
382 responseData["seed_capability"] = seedCapability; 382 responseData["seed_capability"] = seedCapability;
383 responseData["home"] = home; 383 responseData["home"] = home;
384 responseData["look_at"] = lookAt; 384 responseData["look_at"] = lookAt;
385 responseData["message"] = welcomeMessage; 385 responseData["message"] = welcomeMessage;
386 responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); 386 responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize);
387 responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); 387 responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize);
388 388
389 //responseData["inventory-lib-root"] = new ArrayList(); // todo 389 //responseData["inventory-lib-root"] = new ArrayList(); // todo
390 390
391 if (m_buddyList != null) 391 if (m_buddyList != null)
392 { 392 {
393 responseData["buddy-list"] = m_buddyList.ToArray(); 393 responseData["buddy-list"] = m_buddyList.ToArray();
394 } 394 }
395 395
396 responseData["login"] = "true"; 396 responseData["login"] = "true";
397 xmlRpcResponse.Value = responseData; 397 xmlRpcResponse.Value = responseData;
398 398
399 return (xmlRpcResponse); 399 return (xmlRpcResponse);
400 } 400 }
401 catch (Exception e) 401 catch (Exception e)
402 { 402 {
403 m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); 403 m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message);
404 404
405 return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); 405 return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
406 } 406 }
407 } 407 }
408 408
409 public OSD ToLLSDResponse() 409 public OSD ToLLSDResponse()
410 { 410 {
411 try 411 try
412 { 412 {
413 OSDMap map = new OSDMap(); 413 OSDMap map = new OSDMap();
414 414
415 map["first_name"] = OSD.FromString(Firstname); 415 map["first_name"] = OSD.FromString(Firstname);
416 map["last_name"] = OSD.FromString(Lastname); 416 map["last_name"] = OSD.FromString(Lastname);
417 map["agent_access"] = OSD.FromString(agentAccess); 417 map["agent_access"] = OSD.FromString(agentAccess);
418 418
419 map["sim_port"] = OSD.FromInteger(SimPort); 419 map["sim_port"] = OSD.FromInteger(SimPort);
420 map["sim_ip"] = OSD.FromString(SimAddress); 420 map["sim_ip"] = OSD.FromString(SimAddress);
421 421
422 map["agent_id"] = OSD.FromUUID(AgentID); 422 map["agent_id"] = OSD.FromUUID(AgentID);
423 map["session_id"] = OSD.FromUUID(SessionID); 423 map["session_id"] = OSD.FromUUID(SessionID);
424 map["secure_session_id"] = OSD.FromUUID(SecureSessionID); 424 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
425 map["circuit_code"] = OSD.FromInteger(CircuitCode); 425 map["circuit_code"] = OSD.FromInteger(CircuitCode);
426 map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); 426 map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
427 427
428 #region Login Flags 428 #region Login Flags
429 429
430 OSDMap loginFlagsLLSD = new OSDMap(); 430 OSDMap loginFlagsLLSD = new OSDMap();
431 loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); 431 loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST);
432 loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); 432 loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin);
433 loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); 433 loginFlagsLLSD["gendered"] = OSD.FromString(Gendered);
434 loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); 434 loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn);
435 map["login-flags"] = WrapOSDMap(loginFlagsLLSD); 435 map["login-flags"] = WrapOSDMap(loginFlagsLLSD);
436 436
437 #endregion Login Flags 437 #endregion Login Flags
438 438
439 #region Global Textures 439 #region Global Textures
440 440
441 OSDMap globalTexturesLLSD = new OSDMap(); 441 OSDMap globalTexturesLLSD = new OSDMap();
442 globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); 442 globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture);
443 globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); 443 globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture);
444 globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); 444 globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture);
445 445
446 map["global-textures"] = WrapOSDMap(globalTexturesLLSD); 446 map["global-textures"] = WrapOSDMap(globalTexturesLLSD);
447 447
448 #endregion Global Textures 448 #endregion Global Textures
449 449
450 map["seed_capability"] = OSD.FromString(seedCapability); 450 map["seed_capability"] = OSD.FromString(seedCapability);
451 451
452 map["event_categories"] = ArrayListToOSDArray(eventCategories); 452 map["event_categories"] = ArrayListToOSDArray(eventCategories);
453 //map["event_notifications"] = new OSDArray(); // todo 453 //map["event_notifications"] = new OSDArray(); // todo
454 map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); 454 map["classified_categories"] = ArrayListToOSDArray(classifiedCategories);
455 455
456 #region UI Config 456 #region UI Config
457 457
458 OSDMap uiConfigLLSD = new OSDMap(); 458 OSDMap uiConfigLLSD = new OSDMap();
459 uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); 459 uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife);
460 map["ui-config"] = WrapOSDMap(uiConfigLLSD); 460 map["ui-config"] = WrapOSDMap(uiConfigLLSD);
461 461
462 #endregion UI Config 462 #endregion UI Config
463 463
464 #region Inventory 464 #region Inventory
465 465
466 map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); 466 map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory);
467 467
468 map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); 468 map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary);
469 map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; 469 map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ;
470 map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); 470 map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot);
471 map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); 471 map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner);
472 472
473 #endregion Inventory 473 #endregion Inventory
474 474
475 map["gestures"] = ArrayListToOSDArray(activeGestures); 475 map["gestures"] = ArrayListToOSDArray(activeGestures);
476 476
477 map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); 477 map["initial-outfit"] = ArrayListToOSDArray(initialOutfit);
478 map["start_location"] = OSD.FromString(startLocation); 478 map["start_location"] = OSD.FromString(startLocation);
479 479
480 map["seed_capability"] = OSD.FromString(seedCapability); 480 map["seed_capability"] = OSD.FromString(seedCapability);
481 map["home"] = OSD.FromString(home); 481 map["home"] = OSD.FromString(home);
482 map["look_at"] = OSD.FromString(lookAt); 482 map["look_at"] = OSD.FromString(lookAt);
483 map["message"] = OSD.FromString(welcomeMessage); 483 map["message"] = OSD.FromString(welcomeMessage);
484 map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); 484 map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize);
485 map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); 485 map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize);
486 486
487 if (m_buddyList != null) 487 if (m_buddyList != null)
488 { 488 {
489 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); 489 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray());
490 } 490 }
491 491
492 map["login"] = OSD.FromString("true"); 492 map["login"] = OSD.FromString("true");
493 493
494 return map; 494 return map;
495 } 495 }
496 catch (Exception e) 496 catch (Exception e)
497 { 497 {
498 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); 498 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message);
499 499
500 return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); 500 return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false");
501 } 501 }
502 } 502 }
503 503
504 public OSDArray ArrayListToOSDArray(ArrayList arrlst) 504 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
505 { 505 {
506 OSDArray llsdBack = new OSDArray(); 506 OSDArray llsdBack = new OSDArray();
507 foreach (Hashtable ht in arrlst) 507 foreach (Hashtable ht in arrlst)
508 { 508 {
509 OSDMap mp = new OSDMap(); 509 OSDMap mp = new OSDMap();
510 foreach (DictionaryEntry deHt in ht) 510 foreach (DictionaryEntry deHt in ht)
511 { 511 {
512 mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); 512 mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
513 } 513 }
514 llsdBack.Add(mp); 514 llsdBack.Add(mp);
515 } 515 }
516 return llsdBack; 516 return llsdBack;
517 } 517 }
518 518
519 private static OSDArray WrapOSDMap(OSDMap wrapMe) 519 private static OSDArray WrapOSDMap(OSDMap wrapMe)
520 { 520 {
521 OSDArray array = new OSDArray(); 521 OSDArray array = new OSDArray();
522 array.Add(wrapMe); 522 array.Add(wrapMe);
523 return array; 523 return array;
524 } 524 }
525 525
526 public void SetEventCategories(string category, string value) 526 public void SetEventCategories(string category, string value)
527 { 527 {
528 // this.eventCategoriesHash[category] = value; 528 // this.eventCategoriesHash[category] = value;
529 //TODO 529 //TODO
530 } 530 }
531 531
532 public void AddToUIConfig(string itemName, string item) 532 public void AddToUIConfig(string itemName, string item)
533 { 533 {
534 uiConfigHash[itemName] = item; 534 uiConfigHash[itemName] = item;
535 } 535 }
536 536
537 public void AddClassifiedCategory(Int32 ID, string categoryName) 537 public void AddClassifiedCategory(Int32 ID, string categoryName)
538 { 538 {
539 Hashtable hash = new Hashtable(); 539 Hashtable hash = new Hashtable();
540 hash["category_name"] = categoryName; 540 hash["category_name"] = categoryName;
541 hash["category_id"] = ID; 541 hash["category_id"] = ID;
542 classifiedCategories.Add(hash); 542 classifiedCategories.Add(hash);
543 // this.classifiedCategoriesHash.Clear(); 543 // this.classifiedCategoriesHash.Clear();
544 } 544 }
545 545
546 #region Properties 546 #region Properties
547 547
548 public string Login 548 public string Login
549 { 549 {
550 get { return login; } 550 get { return login; }
551 set { login = value; } 551 set { login = value; }
552 } 552 }
553 553
554 public string DST 554 public string DST
555 { 555 {
556 get { return dst; } 556 get { return dst; }
557 set { dst = value; } 557 set { dst = value; }
558 } 558 }
559 559
560 public string StipendSinceLogin 560 public string StipendSinceLogin
561 { 561 {
562 get { return stipendSinceLogin; } 562 get { return stipendSinceLogin; }
563 set { stipendSinceLogin = value; } 563 set { stipendSinceLogin = value; }
564 } 564 }
565 565
566 public string Gendered 566 public string Gendered
567 { 567 {
568 get { return gendered; } 568 get { return gendered; }
569 set { gendered = value; } 569 set { gendered = value; }
570 } 570 }
571 571
572 public string EverLoggedIn 572 public string EverLoggedIn
573 { 573 {
574 get { return everLoggedIn; } 574 get { return everLoggedIn; }
575 set { everLoggedIn = value; } 575 set { everLoggedIn = value; }
576 } 576 }
577 577
578 public uint SimPort 578 public uint SimPort
579 { 579 {
580 get { return simPort; } 580 get { return simPort; }
581 set { simPort = value; } 581 set { simPort = value; }
582 } 582 }
583 583
584 public uint SimHttpPort 584 public uint SimHttpPort
585 { 585 {
586 get { return simHttpPort; } 586 get { return simHttpPort; }
587 set { simHttpPort = value; } 587 set { simHttpPort = value; }
588 } 588 }
589 589
590 public string SimAddress 590 public string SimAddress
591 { 591 {
592 get { return simAddress; } 592 get { return simAddress; }
593 set { simAddress = value; } 593 set { simAddress = value; }
594 } 594 }
595 595
596 public UUID AgentID 596 public UUID AgentID
597 { 597 {
598 get { return agentID; } 598 get { return agentID; }
599 set { agentID = value; } 599 set { agentID = value; }
600 } 600 }
601 601
602 public UUID SessionID 602 public UUID SessionID
603 { 603 {
604 get { return sessionID; } 604 get { return sessionID; }
605 set { sessionID = value; } 605 set { sessionID = value; }
606 } 606 }
607 607
608 public UUID SecureSessionID 608 public UUID SecureSessionID
609 { 609 {
610 get { return secureSessionID; } 610 get { return secureSessionID; }
611 set { secureSessionID = value; } 611 set { secureSessionID = value; }
612 } 612 }
613 613
614 public Int32 CircuitCode 614 public Int32 CircuitCode
615 { 615 {
616 get { return circuitCode; } 616 get { return circuitCode; }
617 set { circuitCode = value; } 617 set { circuitCode = value; }
618 } 618 }
619 619
620 public uint RegionX 620 public uint RegionX
621 { 621 {
622 get { return regionX; } 622 get { return regionX; }
623 set { regionX = value; } 623 set { regionX = value; }
624 } 624 }
625 625
626 public uint RegionY 626 public uint RegionY
627 { 627 {
628 get { return regionY; } 628 get { return regionY; }
629 set { regionY = value; } 629 set { regionY = value; }
630 } 630 }
631 631
632 public string SunTexture 632 public string SunTexture
633 { 633 {
634 get { return sunTexture; } 634 get { return sunTexture; }
635 set { sunTexture = value; } 635 set { sunTexture = value; }
636 } 636 }
637 637
638 public string CloudTexture 638 public string CloudTexture
639 { 639 {
640 get { return cloudTexture; } 640 get { return cloudTexture; }
641 set { cloudTexture = value; } 641 set { cloudTexture = value; }
642 } 642 }
643 643
644 public string MoonTexture 644 public string MoonTexture
645 { 645 {
646 get { return moonTexture; } 646 get { return moonTexture; }
647 set { moonTexture = value; } 647 set { moonTexture = value; }
648 } 648 }
649 649
650 public string Firstname 650 public string Firstname
651 { 651 {
652 get { return firstname; } 652 get { return firstname; }
653 set { firstname = value; } 653 set { firstname = value; }
654 } 654 }
655 655
656 public string Lastname 656 public string Lastname
657 { 657 {
658 get { return lastname; } 658 get { return lastname; }
659 set { lastname = value; } 659 set { lastname = value; }
660 } 660 }
661 661
662 public string AgentAccess 662 public string AgentAccess
663 { 663 {
664 get { return agentAccess; } 664 get { return agentAccess; }
665 set { agentAccess = value; } 665 set { agentAccess = value; }
666 } 666 }
667 667
668 public string StartLocation 668 public string StartLocation
669 { 669 {
670 get { return startLocation; } 670 get { return startLocation; }
671 set { startLocation = value; } 671 set { startLocation = value; }
672 } 672 }
673 673
674 public string LookAt 674 public string LookAt
675 { 675 {
676 get { return lookAt; } 676 get { return lookAt; }
677 set { lookAt = value; } 677 set { lookAt = value; }
678 } 678 }
679 679
680 public string SeedCapability 680 public string SeedCapability
681 { 681 {
682 get { return seedCapability; } 682 get { return seedCapability; }
683 set { seedCapability = value; } 683 set { seedCapability = value; }
684 } 684 }
685 685
686 public string ErrorReason 686 public string ErrorReason
687 { 687 {
688 get { return errorReason; } 688 get { return errorReason; }
689 set { errorReason = value; } 689 set { errorReason = value; }
690 } 690 }
691 691
692 public string ErrorMessage 692 public string ErrorMessage
693 { 693 {
694 get { return errorMessage; } 694 get { return errorMessage; }
695 set { errorMessage = value; } 695 set { errorMessage = value; }
696 } 696 }
697 697
698 public ArrayList InventoryRoot 698 public ArrayList InventoryRoot
699 { 699 {
700 get { return inventoryRoot; } 700 get { return inventoryRoot; }
701 set { inventoryRoot = value; } 701 set { inventoryRoot = value; }
702 } 702 }
703 703
704 public ArrayList InventorySkeleton 704 public ArrayList InventorySkeleton
705 { 705 {
706 get { return agentInventory; } 706 get { return agentInventory; }
707 set { agentInventory = value; } 707 set { agentInventory = value; }
708 } 708 }
709 709
710 public ArrayList InventoryLibrary 710 public ArrayList InventoryLibrary
711 { 711 {
712 get { return inventoryLibrary; } 712 get { return inventoryLibrary; }
713 set { inventoryLibrary = value; } 713 set { inventoryLibrary = value; }
714 } 714 }
715 715
716 public ArrayList InventoryLibraryOwner 716 public ArrayList InventoryLibraryOwner
717 { 717 {
718 get { return inventoryLibraryOwner; } 718 get { return inventoryLibraryOwner; }
719 set { inventoryLibraryOwner = value; } 719 set { inventoryLibraryOwner = value; }
720 } 720 }
721 721
722 public ArrayList InventoryLibRoot 722 public ArrayList InventoryLibRoot
723 { 723 {
724 get { return inventoryLibRoot; } 724 get { return inventoryLibRoot; }
725 set { inventoryLibRoot = value; } 725 set { inventoryLibRoot = value; }
726 } 726 }
727 727
728 public ArrayList ActiveGestures 728 public ArrayList ActiveGestures
729 { 729 {
730 get { return activeGestures; } 730 get { return activeGestures; }
731 set { activeGestures = value; } 731 set { activeGestures = value; }
732 } 732 }
733 733
734 public string Home 734 public string Home
735 { 735 {
736 get { return home; } 736 get { return home; }
737 set { home = value; } 737 set { home = value; }
738 } 738 }
739 739
740 public string Message 740 public string Message
741 { 741 {
742 get { return welcomeMessage; } 742 get { return welcomeMessage; }
743 set { welcomeMessage = value; } 743 set { welcomeMessage = value; }
744 } 744 }
745 745
746 public BuddyList BuddList 746 public BuddyList BuddList
747 { 747 {
748 get { return m_buddyList; } 748 get { return m_buddyList; }
749 set { m_buddyList = value; } 749 set { m_buddyList = value; }
750 } 750 }
751 751
752 #endregion 752 #endregion
753 753
754 public class UserInfo 754 public class UserInfo
755 { 755 {
756 public string firstname; 756 public string firstname;
757 public string lastname; 757 public string lastname;
758 public ulong homeregionhandle; 758 public ulong homeregionhandle;
759 public Vector3 homepos; 759 public Vector3 homepos;
760 public Vector3 homelookat; 760 public Vector3 homelookat;
761 } 761 }
762 762
763 public class BuddyList 763 public class BuddyList
764 { 764 {
765 public List<BuddyInfo> Buddies = new List<BuddyInfo>(); 765 public List<BuddyInfo> Buddies = new List<BuddyInfo>();
766 766
767 public void AddNewBuddy(BuddyInfo buddy) 767 public void AddNewBuddy(BuddyInfo buddy)
768 { 768 {
769 if (!Buddies.Contains(buddy)) 769 if (!Buddies.Contains(buddy))
770 { 770 {
771 Buddies.Add(buddy); 771 Buddies.Add(buddy);
772 } 772 }
773 } 773 }
774 774
775 public ArrayList ToArray() 775 public ArrayList ToArray()
776 { 776 {
777 ArrayList buddyArray = new ArrayList(); 777 ArrayList buddyArray = new ArrayList();
778 foreach (BuddyInfo buddy in Buddies) 778 foreach (BuddyInfo buddy in Buddies)
779 { 779 {
780 buddyArray.Add(buddy.ToHashTable()); 780 buddyArray.Add(buddy.ToHashTable());
781 } 781 }
782 return buddyArray; 782 return buddyArray;
783 } 783 }
784 784
785 public class BuddyInfo 785 public class BuddyInfo
786 { 786 {
787 public int BuddyRightsHave = 1; 787 public int BuddyRightsHave = 1;
788 public int BuddyRightsGiven = 1; 788 public int BuddyRightsGiven = 1;
789 public UUID BuddyID; 789 public UUID BuddyID;
790 790
791 public BuddyInfo(string buddyID) 791 public BuddyInfo(string buddyID)
792 { 792 {
793 BuddyID = new UUID(buddyID); 793 BuddyID = new UUID(buddyID);
794 } 794 }
795 795
796 public BuddyInfo(UUID buddyID) 796 public BuddyInfo(UUID buddyID)
797 { 797 {
798 BuddyID = buddyID; 798 BuddyID = buddyID;
799 } 799 }
800 800
801 public Hashtable ToHashTable() 801 public Hashtable ToHashTable()
802 { 802 {
803 Hashtable hTable = new Hashtable(); 803 Hashtable hTable = new Hashtable();
804 hTable["buddy_rights_has"] = BuddyRightsHave; 804 hTable["buddy_rights_has"] = BuddyRightsHave;
805 hTable["buddy_rights_given"] = BuddyRightsGiven; 805 hTable["buddy_rights_given"] = BuddyRightsGiven;
806 hTable["buddy_id"] = BuddyID.ToString(); 806 hTable["buddy_id"] = BuddyID.ToString();
807 return hTable; 807 return hTable;
808 } 808 }
809 } 809 }
810 } 810 }
811 } 811 }
812} 812}
diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs
index 51158c9..1b6520d 100644
--- a/OpenSim/Framework/Communications/Services/LoginService.cs
+++ b/OpenSim/Framework/Communications/Services/LoginService.cs
@@ -1,1093 +1,1093 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using System.Threading; 34using System.Threading;
35using System.Web; 35using System.Web;
36using log4net; 36using log4net;
37using Nwc.XmlRpc; 37using Nwc.XmlRpc;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenMetaverse.StructuredData; 39using OpenMetaverse.StructuredData;
40using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Statistics; 41using OpenSim.Framework.Statistics;
42 42
43namespace OpenSim.Framework.Communications.Services 43namespace OpenSim.Framework.Communications.Services
44{ 44{
45 public abstract class LoginService 45 public abstract class LoginService
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 protected string m_welcomeMessage = "Welcome to OpenSim"; 49 protected string m_welcomeMessage = "Welcome to OpenSim";
50 protected int m_minLoginLevel = 0; 50 protected int m_minLoginLevel = 0;
51 protected UserManagerBase m_userManager = null; 51 protected UserManagerBase m_userManager = null;
52 protected Mutex m_loginMutex = new Mutex(false); 52 protected Mutex m_loginMutex = new Mutex(false);
53 53
54 /// <summary> 54 /// <summary>
55 /// Used during login to send the skeleton of the OpenSim Library to the client. 55 /// Used during login to send the skeleton of the OpenSim Library to the client.
56 /// </summary> 56 /// </summary>
57 protected LibraryRootFolder m_libraryRootFolder; 57 protected LibraryRootFolder m_libraryRootFolder;
58 58
59 protected uint m_defaultHomeX; 59 protected uint m_defaultHomeX;
60 protected uint m_defaultHomeY; 60 protected uint m_defaultHomeY;
61 61
62 /// <summary> 62 /// <summary>
63 /// Used by the login service to make requests to the inventory service. 63 /// Used by the login service to make requests to the inventory service.
64 /// </summary> 64 /// </summary>
65 protected IInterServiceInventoryServices m_inventoryService; 65 protected IInterServiceInventoryServices m_inventoryService;
66 66
67 /// <summary> 67 /// <summary>
68 /// Constructor 68 /// Constructor
69 /// </summary> 69 /// </summary>
70 /// <param name="userManager"></param> 70 /// <param name="userManager"></param>
71 /// <param name="libraryRootFolder"></param> 71 /// <param name="libraryRootFolder"></param>
72 /// <param name="welcomeMess"></param> 72 /// <param name="welcomeMess"></param>
73 public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder, 73 public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
74 string welcomeMess) 74 string welcomeMess)
75 { 75 {
76 m_userManager = userManager; 76 m_userManager = userManager;
77 m_libraryRootFolder = libraryRootFolder; 77 m_libraryRootFolder = libraryRootFolder;
78 78
79 if (welcomeMess != String.Empty) 79 if (welcomeMess != String.Empty)
80 { 80 {
81 m_welcomeMessage = welcomeMess; 81 m_welcomeMessage = welcomeMess;
82 } 82 }
83 } 83 }
84 84
85 /// <summary> 85 /// <summary>
86 /// If the user is already logged in, try to notify the region that the user they've got is dead. 86 /// If the user is already logged in, try to notify the region that the user they've got is dead.
87 /// </summary> 87 /// </summary>
88 /// <param name="theUser"></param> 88 /// <param name="theUser"></param>
89 public virtual void LogOffUser(UserProfileData theUser, string message) 89 public virtual void LogOffUser(UserProfileData theUser, string message)
90 { 90 {
91 } 91 }
92 92
93 93
94 /// <summary> 94 /// <summary>
95 /// Called when we receive the client's initial XMLRPC login_to_simulator request message 95 /// Called when we receive the client's initial XMLRPC login_to_simulator request message
96 /// </summary> 96 /// </summary>
97 /// <param name="request">The XMLRPC request</param> 97 /// <param name="request">The XMLRPC request</param>
98 /// <returns>The response to send</returns> 98 /// <returns>The response to send</returns>
99 public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) 99 public virtual XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
100 { 100 {
101 // Temporary fix 101 // Temporary fix
102 m_loginMutex.WaitOne(); 102 m_loginMutex.WaitOne();
103 103
104 try 104 try
105 { 105 {
106 //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. 106 //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this.
107 //CKF: m_log.Info("[LOGIN]: Attempting login now..."); 107 //CKF: m_log.Info("[LOGIN]: Attempting login now...");
108 XmlRpcResponse response = new XmlRpcResponse(); 108 XmlRpcResponse response = new XmlRpcResponse();
109 Hashtable requestData = (Hashtable)request.Params[0]; 109 Hashtable requestData = (Hashtable)request.Params[0];
110 110
111 SniffLoginKey((Uri)request.Params[2], requestData); 111 SniffLoginKey((Uri)request.Params[2], requestData);
112 112
113 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && 113 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") &&
114 (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); 114 (requestData.Contains("passwd") || requestData.Contains("web_login_key")));
115 115
116 string startLocationRequest = "last"; 116 string startLocationRequest = "last";
117 117
118 UserProfileData userProfile; 118 UserProfileData userProfile;
119 LoginResponse logResponse = new LoginResponse(); 119 LoginResponse logResponse = new LoginResponse();
120 120
121 string firstname; 121 string firstname;
122 string lastname; 122 string lastname;
123 123
124 if (GoodXML) 124 if (GoodXML)
125 { 125 {
126 if (requestData.Contains("start")) 126 if (requestData.Contains("start"))
127 { 127 {
128 startLocationRequest = (string)requestData["start"]; 128 startLocationRequest = (string)requestData["start"];
129 } 129 }
130 130
131 firstname = (string)requestData["first"]; 131 firstname = (string)requestData["first"];
132 lastname = (string)requestData["last"]; 132 lastname = (string)requestData["last"];
133 133
134 m_log.InfoFormat( 134 m_log.InfoFormat(
135 "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'", 135 "[LOGIN BEGIN]: XMLRPC Received login request message from user '{0}' '{1}'",
136 firstname, lastname); 136 firstname, lastname);
137 137
138 string clientVersion = "Unknown"; 138 string clientVersion = "Unknown";
139 139
140 if (requestData.Contains("version")) 140 if (requestData.Contains("version"))
141 { 141 {
142 clientVersion = (string)requestData["version"]; 142 clientVersion = (string)requestData["version"];
143 } 143 }
144 144
145 m_log.DebugFormat( 145 m_log.DebugFormat(
146 "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); 146 "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest);
147 147
148 if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile)) 148 if (!TryAuthenticateXmlRpcLogin(request, firstname, lastname, out userProfile))
149 { 149 {
150 return logResponse.CreateLoginFailedResponse(); 150 return logResponse.CreateLoginFailedResponse();
151 } 151 }
152 } 152 }
153 else 153 else
154 { 154 {
155 m_log.Info( 155 m_log.Info(
156 "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data"); 156 "[LOGIN END]: XMLRPC login_to_simulator login message did not contain all the required data");
157 157
158 return logResponse.CreateGridErrorResponse(); 158 return logResponse.CreateGridErrorResponse();
159 } 159 }
160 160
161 if (userProfile.GodLevel < m_minLoginLevel) 161 if (userProfile.GodLevel < m_minLoginLevel)
162 { 162 {
163 return logResponse.CreateLoginBlockedResponse(); 163 return logResponse.CreateLoginBlockedResponse();
164 } 164 }
165 else 165 else
166 { 166 {
167 // If we already have a session... 167 // If we already have a session...
168 if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) 168 if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline)
169 { 169 {
170 //TODO: The following statements can cause trouble: 170 //TODO: The following statements can cause trouble:
171 // If agentOnline could not turn from true back to false normally 171 // If agentOnline could not turn from true back to false normally
172 // because of some problem, for instance, the crashment of server or client, 172 // because of some problem, for instance, the crashment of server or client,
173 // the user cannot log in any longer. 173 // the user cannot log in any longer.
174 userProfile.CurrentAgent.AgentOnline = false; 174 userProfile.CurrentAgent.AgentOnline = false;
175 175
176 m_userManager.CommitAgent(ref userProfile); 176 m_userManager.CommitAgent(ref userProfile);
177 177
178 // try to tell the region that their user is dead. 178 // try to tell the region that their user is dead.
179 LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location"); 179 LogOffUser(userProfile, " XMLRPC You were logged off because you logged in from another location");
180 180
181 // Reject the login 181 // Reject the login
182 182
183 m_log.InfoFormat( 183 m_log.InfoFormat(
184 "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in", 184 "[LOGIN END]: XMLRPC Notifying user {0} {1} that they are already logged in",
185 firstname, lastname); 185 firstname, lastname);
186 186
187 return logResponse.CreateAlreadyLoggedInResponse(); 187 return logResponse.CreateAlreadyLoggedInResponse();
188 } 188 }
189 189
190 // Otherwise... 190 // Otherwise...
191 // Create a new agent session 191 // Create a new agent session
192 192
193 m_userManager.ResetAttachments(userProfile.ID); 193 m_userManager.ResetAttachments(userProfile.ID);
194 194
195 CreateAgent(userProfile, request); 195 CreateAgent(userProfile, request);
196 196
197 try 197 try
198 { 198 {
199 UUID agentID = userProfile.ID; 199 UUID agentID = userProfile.ID;
200 InventoryData inventData; 200 InventoryData inventData;
201 201
202 try 202 try
203 { 203 {
204 inventData = GetInventorySkeleton(agentID); 204 inventData = GetInventorySkeleton(agentID);
205 } 205 }
206 catch (Exception e) 206 catch (Exception e)
207 { 207 {
208 m_log.ErrorFormat( 208 m_log.ErrorFormat(
209 "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}", 209 "[LOGIN END]: Error retrieving inventory skeleton of agent {0} - {1}",
210 agentID, e); 210 agentID, e);
211 211
212 return logResponse.CreateLoginInventoryFailedResponse(); 212 return logResponse.CreateLoginInventoryFailedResponse();
213 } 213 }
214 214
215 ArrayList AgentInventoryArray = inventData.InventoryArray; 215 ArrayList AgentInventoryArray = inventData.InventoryArray;
216 216
217 Hashtable InventoryRootHash = new Hashtable(); 217 Hashtable InventoryRootHash = new Hashtable();
218 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); 218 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
219 ArrayList InventoryRoot = new ArrayList(); 219 ArrayList InventoryRoot = new ArrayList();
220 InventoryRoot.Add(InventoryRootHash); 220 InventoryRoot.Add(InventoryRootHash);
221 userProfile.RootInventoryFolderID = inventData.RootFolderID; 221 userProfile.RootInventoryFolderID = inventData.RootFolderID;
222 222
223 // Inventory Library Section 223 // Inventory Library Section
224 Hashtable InventoryLibRootHash = new Hashtable(); 224 Hashtable InventoryLibRootHash = new Hashtable();
225 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 225 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
226 ArrayList InventoryLibRoot = new ArrayList(); 226 ArrayList InventoryLibRoot = new ArrayList();
227 InventoryLibRoot.Add(InventoryLibRootHash); 227 InventoryLibRoot.Add(InventoryLibRootHash);
228 228
229 logResponse.InventoryLibRoot = InventoryLibRoot; 229 logResponse.InventoryLibRoot = InventoryLibRoot;
230 logResponse.InventoryLibraryOwner = GetLibraryOwner(); 230 logResponse.InventoryLibraryOwner = GetLibraryOwner();
231 logResponse.InventoryRoot = InventoryRoot; 231 logResponse.InventoryRoot = InventoryRoot;
232 logResponse.InventorySkeleton = AgentInventoryArray; 232 logResponse.InventorySkeleton = AgentInventoryArray;
233 logResponse.InventoryLibrary = GetInventoryLibrary(); 233 logResponse.InventoryLibrary = GetInventoryLibrary();
234 234
235 logResponse.CircuitCode = Util.RandomClass.Next(); 235 logResponse.CircuitCode = Util.RandomClass.Next();
236 logResponse.Lastname = userProfile.SurName; 236 logResponse.Lastname = userProfile.SurName;
237 logResponse.Firstname = userProfile.FirstName; 237 logResponse.Firstname = userProfile.FirstName;
238 logResponse.AgentID = agentID; 238 logResponse.AgentID = agentID;
239 logResponse.SessionID = userProfile.CurrentAgent.SessionID; 239 logResponse.SessionID = userProfile.CurrentAgent.SessionID;
240 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; 240 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID;
241 logResponse.Message = GetMessage(); 241 logResponse.Message = GetMessage();
242 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); 242 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
243 logResponse.StartLocation = startLocationRequest; 243 logResponse.StartLocation = startLocationRequest;
244 244
245 if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) 245 if (CustomiseResponse(logResponse, userProfile, startLocationRequest))
246 { 246 {
247 userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; 247 userProfile.LastLogin = userProfile.CurrentAgent.LoginTime;
248 CommitAgent(ref userProfile); 248 CommitAgent(ref userProfile);
249 249
250 // If we reach this point, then the login has successfully logged onto the grid 250 // If we reach this point, then the login has successfully logged onto the grid
251 if (StatsManager.UserStats != null) 251 if (StatsManager.UserStats != null)
252 StatsManager.UserStats.AddSuccessfulLogin(); 252 StatsManager.UserStats.AddSuccessfulLogin();
253 253
254 m_log.DebugFormat( 254 m_log.DebugFormat(
255 "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", 255 "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.",
256 firstname, lastname); 256 firstname, lastname);
257 257
258 return logResponse.ToXmlRpcResponse(); 258 return logResponse.ToXmlRpcResponse();
259 } 259 }
260 else 260 else
261 { 261 {
262 m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); 262 m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname);
263 return logResponse.CreateDeadRegionResponse(); 263 return logResponse.CreateDeadRegionResponse();
264 } 264 }
265 } 265 }
266 catch (Exception e) 266 catch (Exception e)
267 { 267 {
268 m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e); 268 m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e);
269 m_log.Error(e.StackTrace); 269 m_log.Error(e.StackTrace);
270 } 270 }
271 } 271 }
272 272
273 m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response"); 273 m_log.Info("[LOGIN END]: XMLRPC Login failed. Sending back blank XMLRPC response");
274 return response; 274 return response;
275 } 275 }
276 finally 276 finally
277 { 277 {
278 m_loginMutex.ReleaseMutex(); 278 m_loginMutex.ReleaseMutex();
279 } 279 }
280 } 280 }
281 281
282 protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile) 282 protected virtual bool TryAuthenticateXmlRpcLogin(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile)
283 { 283 {
284 Hashtable requestData = (Hashtable)request.Params[0]; 284 Hashtable requestData = (Hashtable)request.Params[0];
285 285
286 bool GoodLogin = false; 286 bool GoodLogin = false;
287 287
288 userProfile = GetTheUser(firstname, lastname); 288 userProfile = GetTheUser(firstname, lastname);
289 if (userProfile == null) 289 if (userProfile == null)
290 { 290 {
291 m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname); 291 m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname);
292 } 292 }
293 else 293 else
294 { 294 {
295 if (requestData.Contains("passwd")) 295 if (requestData.Contains("passwd"))
296 { 296 {
297 string passwd = (string)requestData["passwd"]; 297 string passwd = (string)requestData["passwd"];
298 GoodLogin = AuthenticateUser(userProfile, passwd); 298 GoodLogin = AuthenticateUser(userProfile, passwd);
299 } 299 }
300 if (!GoodLogin && (requestData.Contains("web_login_key"))) 300 if (!GoodLogin && (requestData.Contains("web_login_key")))
301 { 301 {
302 try 302 try
303 { 303 {
304 UUID webloginkey = new UUID((string)requestData["web_login_key"]); 304 UUID webloginkey = new UUID((string)requestData["web_login_key"]);
305 GoodLogin = AuthenticateUser(userProfile, webloginkey); 305 GoodLogin = AuthenticateUser(userProfile, webloginkey);
306 } 306 }
307 catch (Exception e) 307 catch (Exception e)
308 { 308 {
309 m_log.InfoFormat( 309 m_log.InfoFormat(
310 "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}", 310 "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}",
311 requestData["web_login_key"], firstname, lastname, e); 311 requestData["web_login_key"], firstname, lastname, e);
312 } 312 }
313 } 313 }
314 } 314 }
315 315
316 return GoodLogin; 316 return GoodLogin;
317 } 317 }
318 318
319 protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile) 319 protected virtual bool TryAuthenticateLLSDLogin(string firstname, string lastname, string passwd, out UserProfileData userProfile)
320 { 320 {
321 bool GoodLogin = false; 321 bool GoodLogin = false;
322 userProfile = GetTheUser(firstname, lastname); 322 userProfile = GetTheUser(firstname, lastname);
323 if (userProfile == null) 323 if (userProfile == null)
324 { 324 {
325 m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname); 325 m_log.Info("[LOGIN]: LLSD Could not find a profile for " + firstname + " " + lastname);
326 326
327 return false; 327 return false;
328 } 328 }
329 329
330 GoodLogin = AuthenticateUser(userProfile, passwd); 330 GoodLogin = AuthenticateUser(userProfile, passwd);
331 return GoodLogin; 331 return GoodLogin;
332 } 332 }
333 333
334 /// <summary> 334 /// <summary>
335 /// Called when we receive the client's initial LLSD login_to_simulator request message 335 /// Called when we receive the client's initial LLSD login_to_simulator request message
336 /// </summary> 336 /// </summary>
337 /// <param name="request">The LLSD request</param> 337 /// <param name="request">The LLSD request</param>
338 /// <returns>The response to send</returns> 338 /// <returns>The response to send</returns>
339 public OSD LLSDLoginMethod(OSD request) 339 public OSD LLSDLoginMethod(OSD request)
340 { 340 {
341 // Temporary fix 341 // Temporary fix
342 m_loginMutex.WaitOne(); 342 m_loginMutex.WaitOne();
343 343
344 try 344 try
345 { 345 {
346 // bool GoodLogin = false; 346 // bool GoodLogin = false;
347 347
348 string startLocationRequest = "last"; 348 string startLocationRequest = "last";
349 349
350 UserProfileData userProfile = null; 350 UserProfileData userProfile = null;
351 LoginResponse logResponse = new LoginResponse(); 351 LoginResponse logResponse = new LoginResponse();
352 352
353 if (request.Type == OSDType.Map) 353 if (request.Type == OSDType.Map)
354 { 354 {
355 OSDMap map = (OSDMap)request; 355 OSDMap map = (OSDMap)request;
356 356
357 if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd")) 357 if (map.ContainsKey("first") && map.ContainsKey("last") && map.ContainsKey("passwd"))
358 { 358 {
359 string firstname = map["first"].AsString(); 359 string firstname = map["first"].AsString();
360 string lastname = map["last"].AsString(); 360 string lastname = map["last"].AsString();
361 string passwd = map["passwd"].AsString(); 361 string passwd = map["passwd"].AsString();
362 362
363 if (map.ContainsKey("start")) 363 if (map.ContainsKey("start"))
364 { 364 {
365 m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString()); 365 m_log.Info("[LOGIN]: LLSD StartLocation Requested: " + map["start"].AsString());
366 startLocationRequest = map["start"].AsString(); 366 startLocationRequest = map["start"].AsString();
367 } 367 }
368 m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd); 368 m_log.Info("[LOGIN]: LLSD Login Requested for: '" + firstname + "' '" + lastname + "' / " + passwd);
369 369
370 if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile)) 370 if (!TryAuthenticateLLSDLogin(firstname, lastname, passwd, out userProfile))
371 { 371 {
372 return logResponse.CreateLoginFailedResponseLLSD(); 372 return logResponse.CreateLoginFailedResponseLLSD();
373 } 373 }
374 } 374 }
375 else 375 else
376 return logResponse.CreateLoginFailedResponseLLSD(); 376 return logResponse.CreateLoginFailedResponseLLSD();
377 } 377 }
378 else 378 else
379 return logResponse.CreateLoginFailedResponseLLSD(); 379 return logResponse.CreateLoginFailedResponseLLSD();
380 380
381 381
382 if (userProfile.GodLevel < m_minLoginLevel) 382 if (userProfile.GodLevel < m_minLoginLevel)
383 { 383 {
384 return logResponse.CreateLoginBlockedResponseLLSD(); 384 return logResponse.CreateLoginBlockedResponseLLSD();
385 } 385 }
386 else 386 else
387 { 387 {
388 // If we already have a session... 388 // If we already have a session...
389 if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline) 389 if (userProfile.CurrentAgent != null && userProfile.CurrentAgent.AgentOnline)
390 { 390 {
391 userProfile.CurrentAgent.AgentOnline = false; 391 userProfile.CurrentAgent.AgentOnline = false;
392 392
393 m_userManager.CommitAgent(ref userProfile); 393 m_userManager.CommitAgent(ref userProfile);
394 // try to tell the region that their user is dead. 394 // try to tell the region that their user is dead.
395 LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location"); 395 LogOffUser(userProfile, " LLSD You were logged off because you logged in from another location");
396 396
397 // Reject the login 397 // Reject the login
398 398
399 m_log.InfoFormat( 399 m_log.InfoFormat(
400 "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in", 400 "[LOGIN END]: LLSD Notifying user {0} {1} that they are already logged in",
401 userProfile.FirstName, userProfile.SurName); 401 userProfile.FirstName, userProfile.SurName);
402 402
403 userProfile.CurrentAgent = null; 403 userProfile.CurrentAgent = null;
404 return logResponse.CreateAlreadyLoggedInResponseLLSD(); 404 return logResponse.CreateAlreadyLoggedInResponseLLSD();
405 } 405 }
406 406
407 // Otherwise... 407 // Otherwise...
408 // Create a new agent session 408 // Create a new agent session
409 409
410 m_userManager.ResetAttachments(userProfile.ID); 410 m_userManager.ResetAttachments(userProfile.ID);
411 411
412 CreateAgent(userProfile, request); 412 CreateAgent(userProfile, request);
413 413
414 try 414 try
415 { 415 {
416 UUID agentID = userProfile.ID; 416 UUID agentID = userProfile.ID;
417 417
418 //InventoryData inventData = GetInventorySkeleton(agentID); 418 //InventoryData inventData = GetInventorySkeleton(agentID);
419 InventoryData inventData = null; 419 InventoryData inventData = null;
420 420
421 try 421 try
422 { 422 {
423 inventData = GetInventorySkeleton(agentID); 423 inventData = GetInventorySkeleton(agentID);
424 } 424 }
425 catch (Exception e) 425 catch (Exception e)
426 { 426 {
427 m_log.ErrorFormat( 427 m_log.ErrorFormat(
428 "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}", 428 "[LOGIN END]: LLSD Error retrieving inventory skeleton of agent {0}, {1} - {2}",
429 agentID, e.GetType(), e.Message); 429 agentID, e.GetType(), e.Message);
430 430
431 return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD (); 431 return logResponse.CreateLoginFailedResponseLLSD();// .CreateLoginInventoryFailedResponseLLSD ();
432 } 432 }
433 433
434 434
435 ArrayList AgentInventoryArray = inventData.InventoryArray; 435 ArrayList AgentInventoryArray = inventData.InventoryArray;
436 436
437 Hashtable InventoryRootHash = new Hashtable(); 437 Hashtable InventoryRootHash = new Hashtable();
438 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); 438 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
439 ArrayList InventoryRoot = new ArrayList(); 439 ArrayList InventoryRoot = new ArrayList();
440 InventoryRoot.Add(InventoryRootHash); 440 InventoryRoot.Add(InventoryRootHash);
441 userProfile.RootInventoryFolderID = inventData.RootFolderID; 441 userProfile.RootInventoryFolderID = inventData.RootFolderID;
442 442
443 443
444 // Inventory Library Section 444 // Inventory Library Section
445 Hashtable InventoryLibRootHash = new Hashtable(); 445 Hashtable InventoryLibRootHash = new Hashtable();
446 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 446 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
447 ArrayList InventoryLibRoot = new ArrayList(); 447 ArrayList InventoryLibRoot = new ArrayList();
448 InventoryLibRoot.Add(InventoryLibRootHash); 448 InventoryLibRoot.Add(InventoryLibRootHash);
449 449
450 logResponse.InventoryLibRoot = InventoryLibRoot; 450 logResponse.InventoryLibRoot = InventoryLibRoot;
451 logResponse.InventoryLibraryOwner = GetLibraryOwner(); 451 logResponse.InventoryLibraryOwner = GetLibraryOwner();
452 logResponse.InventoryRoot = InventoryRoot; 452 logResponse.InventoryRoot = InventoryRoot;
453 logResponse.InventorySkeleton = AgentInventoryArray; 453 logResponse.InventorySkeleton = AgentInventoryArray;
454 logResponse.InventoryLibrary = GetInventoryLibrary(); 454 logResponse.InventoryLibrary = GetInventoryLibrary();
455 455
456 logResponse.CircuitCode = (Int32)Util.RandomClass.Next(); 456 logResponse.CircuitCode = (Int32)Util.RandomClass.Next();
457 logResponse.Lastname = userProfile.SurName; 457 logResponse.Lastname = userProfile.SurName;
458 logResponse.Firstname = userProfile.FirstName; 458 logResponse.Firstname = userProfile.FirstName;
459 logResponse.AgentID = agentID; 459 logResponse.AgentID = agentID;
460 logResponse.SessionID = userProfile.CurrentAgent.SessionID; 460 logResponse.SessionID = userProfile.CurrentAgent.SessionID;
461 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; 461 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID;
462 logResponse.Message = GetMessage(); 462 logResponse.Message = GetMessage();
463 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); 463 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
464 logResponse.StartLocation = startLocationRequest; 464 logResponse.StartLocation = startLocationRequest;
465 465
466 try 466 try
467 { 467 {
468 CustomiseResponse(logResponse, userProfile, startLocationRequest); 468 CustomiseResponse(logResponse, userProfile, startLocationRequest);
469 } 469 }
470 catch (Exception ex) 470 catch (Exception ex)
471 { 471 {
472 m_log.Info("[LOGIN]: LLSD " + ex.ToString()); 472 m_log.Info("[LOGIN]: LLSD " + ex.ToString());
473 return logResponse.CreateDeadRegionResponseLLSD(); 473 return logResponse.CreateDeadRegionResponseLLSD();
474 } 474 }
475 475
476 userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; 476 userProfile.LastLogin = userProfile.CurrentAgent.LoginTime;
477 CommitAgent(ref userProfile); 477 CommitAgent(ref userProfile);
478 478
479 // If we reach this point, then the login has successfully logged onto the grid 479 // If we reach this point, then the login has successfully logged onto the grid
480 if (StatsManager.UserStats != null) 480 if (StatsManager.UserStats != null)
481 StatsManager.UserStats.AddSuccessfulLogin(); 481 StatsManager.UserStats.AddSuccessfulLogin();
482 482
483 m_log.DebugFormat( 483 m_log.DebugFormat(
484 "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.", 484 "[LOGIN END]: LLSD Authentication of user {0} {1} successful. Sending response to client.",
485 userProfile.FirstName, userProfile.SurName); 485 userProfile.FirstName, userProfile.SurName);
486 486
487 return logResponse.ToLLSDResponse(); 487 return logResponse.ToLLSDResponse();
488 } 488 }
489 catch (Exception ex) 489 catch (Exception ex)
490 { 490 {
491 m_log.Info("[LOGIN]: LLSD " + ex.ToString()); 491 m_log.Info("[LOGIN]: LLSD " + ex.ToString());
492 return logResponse.CreateFailedResponseLLSD(); 492 return logResponse.CreateFailedResponseLLSD();
493 } 493 }
494 } 494 }
495 } 495 }
496 finally 496 finally
497 { 497 {
498 m_loginMutex.ReleaseMutex(); 498 m_loginMutex.ReleaseMutex();
499 } 499 }
500 } 500 }
501 501
502 public Hashtable ProcessHTMLLogin(Hashtable keysvals) 502 public Hashtable ProcessHTMLLogin(Hashtable keysvals)
503 { 503 {
504 // Matches all unspecified characters 504 // Matches all unspecified characters
505 // Currently specified,; lowercase letters, upper case letters, numbers, underline 505 // Currently specified,; lowercase letters, upper case letters, numbers, underline
506 // period, space, parens, and dash. 506 // period, space, parens, and dash.
507 507
508 Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]"); 508 Regex wfcut = new Regex("[^a-zA-Z0-9_\\.\\$ \\(\\)\\-]");
509 509
510 Hashtable returnactions = new Hashtable(); 510 Hashtable returnactions = new Hashtable();
511 int statuscode = 200; 511 int statuscode = 200;
512 512
513 string firstname = String.Empty; 513 string firstname = String.Empty;
514 string lastname = String.Empty; 514 string lastname = String.Empty;
515 string location = String.Empty; 515 string location = String.Empty;
516 string region = String.Empty; 516 string region = String.Empty;
517 string grid = String.Empty; 517 string grid = String.Empty;
518 string channel = String.Empty; 518 string channel = String.Empty;
519 string version = String.Empty; 519 string version = String.Empty;
520 string lang = String.Empty; 520 string lang = String.Empty;
521 string password = String.Empty; 521 string password = String.Empty;
522 string errormessages = String.Empty; 522 string errormessages = String.Empty;
523 523
524 // the client requires the HTML form field be named 'username' 524 // the client requires the HTML form field be named 'username'
525 // however, the data it sends when it loads the first time is 'firstname' 525 // however, the data it sends when it loads the first time is 'firstname'
526 // another one of those little nuances. 526 // another one of those little nuances.
527 527
528 if (keysvals.Contains("firstname")) 528 if (keysvals.Contains("firstname"))
529 firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999); 529 firstname = wfcut.Replace((string)keysvals["firstname"], String.Empty, 99999);
530 530
531 if (keysvals.Contains("username")) 531 if (keysvals.Contains("username"))
532 firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999); 532 firstname = wfcut.Replace((string)keysvals["username"], String.Empty, 99999);
533 533
534 if (keysvals.Contains("lastname")) 534 if (keysvals.Contains("lastname"))
535 lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999); 535 lastname = wfcut.Replace((string)keysvals["lastname"], String.Empty, 99999);
536 536
537 if (keysvals.Contains("location")) 537 if (keysvals.Contains("location"))
538 location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999); 538 location = wfcut.Replace((string)keysvals["location"], String.Empty, 99999);
539 539
540 if (keysvals.Contains("region")) 540 if (keysvals.Contains("region"))
541 region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999); 541 region = wfcut.Replace((string)keysvals["region"], String.Empty, 99999);
542 542
543 if (keysvals.Contains("grid")) 543 if (keysvals.Contains("grid"))
544 grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999); 544 grid = wfcut.Replace((string)keysvals["grid"], String.Empty, 99999);
545 545
546 if (keysvals.Contains("channel")) 546 if (keysvals.Contains("channel"))
547 channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999); 547 channel = wfcut.Replace((string)keysvals["channel"], String.Empty, 99999);
548 548
549 if (keysvals.Contains("version")) 549 if (keysvals.Contains("version"))
550 version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999); 550 version = wfcut.Replace((string)keysvals["version"], String.Empty, 99999);
551 551
552 if (keysvals.Contains("lang")) 552 if (keysvals.Contains("lang"))
553 lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999); 553 lang = wfcut.Replace((string)keysvals["lang"], String.Empty, 99999);
554 554
555 if (keysvals.Contains("password")) 555 if (keysvals.Contains("password"))
556 password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999); 556 password = wfcut.Replace((string)keysvals["password"], String.Empty, 99999);
557 557
558 // load our login form. 558 // load our login form.
559 string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); 559 string loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages);
560 560
561 if (keysvals.ContainsKey("show_login_form")) 561 if (keysvals.ContainsKey("show_login_form"))
562 { 562 {
563 UserProfileData user = GetTheUser(firstname, lastname); 563 UserProfileData user = GetTheUser(firstname, lastname);
564 bool goodweblogin = false; 564 bool goodweblogin = false;
565 565
566 if (user != null) 566 if (user != null)
567 goodweblogin = AuthenticateUser(user, password); 567 goodweblogin = AuthenticateUser(user, password);
568 568
569 if (goodweblogin) 569 if (goodweblogin)
570 { 570 {
571 UUID webloginkey = UUID.Random(); 571 UUID webloginkey = UUID.Random();
572 m_userManager.StoreWebLoginKey(user.ID, webloginkey); 572 m_userManager.StoreWebLoginKey(user.ID, webloginkey);
573 //statuscode = 301; 573 //statuscode = 301;
574 574
575 // string redirectURL = "about:blank?redirect-http-hack=" + 575 // string redirectURL = "about:blank?redirect-http-hack=" +
576 // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + 576 // HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" +
577 // lastname + 577 // lastname +
578 // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); 578 // "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString());
579 //m_log.Info("[WEB]: R:" + redirectURL); 579 //m_log.Info("[WEB]: R:" + redirectURL);
580 returnactions["int_response_code"] = statuscode; 580 returnactions["int_response_code"] = statuscode;
581 //returnactions["str_redirect_location"] = redirectURL; 581 //returnactions["str_redirect_location"] = redirectURL;
582 //returnactions["str_response_string"] = "<HTML><BODY>GoodLogin</BODY></HTML>"; 582 //returnactions["str_response_string"] = "<HTML><BODY>GoodLogin</BODY></HTML>";
583 returnactions["str_response_string"] = webloginkey.ToString(); 583 returnactions["str_response_string"] = webloginkey.ToString();
584 } 584 }
585 else 585 else
586 { 586 {
587 errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; 587 errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again";
588 588
589 loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); 589 loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages);
590 returnactions["int_response_code"] = statuscode; 590 returnactions["int_response_code"] = statuscode;
591 returnactions["str_response_string"] = loginform; 591 returnactions["str_response_string"] = loginform;
592 } 592 }
593 } 593 }
594 else 594 else
595 { 595 {
596 returnactions["int_response_code"] = statuscode; 596 returnactions["int_response_code"] = statuscode;
597 returnactions["str_response_string"] = loginform; 597 returnactions["str_response_string"] = loginform;
598 } 598 }
599 return returnactions; 599 return returnactions;
600 } 600 }
601 601
602 public string GetLoginForm(string firstname, string lastname, string location, string region, 602 public string GetLoginForm(string firstname, string lastname, string location, string region,
603 string grid, string channel, string version, string lang, 603 string grid, string channel, string version, string lang,
604 string password, string errormessages) 604 string password, string errormessages)
605 { 605 {
606 // inject our values in the form at the markers 606 // inject our values in the form at the markers
607 607
608 string loginform = String.Empty; 608 string loginform = String.Empty;
609 string file = Path.Combine(Util.configDir(), "http_loginform.html"); 609 string file = Path.Combine(Util.configDir(), "http_loginform.html");
610 if (!File.Exists(file)) 610 if (!File.Exists(file))
611 { 611 {
612 loginform = GetDefaultLoginForm(); 612 loginform = GetDefaultLoginForm();
613 } 613 }
614 else 614 else
615 { 615 {
616 StreamReader sr = File.OpenText(file); 616 StreamReader sr = File.OpenText(file);
617 loginform = sr.ReadToEnd(); 617 loginform = sr.ReadToEnd();
618 sr.Close(); 618 sr.Close();
619 } 619 }
620 620
621 loginform = loginform.Replace("[$firstname]", firstname); 621 loginform = loginform.Replace("[$firstname]", firstname);
622 loginform = loginform.Replace("[$lastname]", lastname); 622 loginform = loginform.Replace("[$lastname]", lastname);
623 loginform = loginform.Replace("[$location]", location); 623 loginform = loginform.Replace("[$location]", location);
624 loginform = loginform.Replace("[$region]", region); 624 loginform = loginform.Replace("[$region]", region);
625 loginform = loginform.Replace("[$grid]", grid); 625 loginform = loginform.Replace("[$grid]", grid);
626 loginform = loginform.Replace("[$channel]", channel); 626 loginform = loginform.Replace("[$channel]", channel);
627 loginform = loginform.Replace("[$version]", version); 627 loginform = loginform.Replace("[$version]", version);
628 loginform = loginform.Replace("[$lang]", lang); 628 loginform = loginform.Replace("[$lang]", lang);
629 loginform = loginform.Replace("[$password]", password); 629 loginform = loginform.Replace("[$password]", password);
630 loginform = loginform.Replace("[$errors]", errormessages); 630 loginform = loginform.Replace("[$errors]", errormessages);
631 631
632 return loginform; 632 return loginform;
633 } 633 }
634 634
635 public string GetDefaultLoginForm() 635 public string GetDefaultLoginForm()
636 { 636 {
637 string responseString = 637 string responseString =
638 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; 638 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
639 responseString += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; 639 responseString += "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
640 responseString += "<head>"; 640 responseString += "<head>";
641 responseString += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; 641 responseString += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
642 responseString += "<meta http-equiv=\"cache-control\" content=\"no-cache\">"; 642 responseString += "<meta http-equiv=\"cache-control\" content=\"no-cache\">";
643 responseString += "<meta http-equiv=\"Pragma\" content=\"no-cache\">"; 643 responseString += "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
644 responseString += "<title>OpenSim Login</title>"; 644 responseString += "<title>OpenSim Login</title>";
645 responseString += "<body><br />"; 645 responseString += "<body><br />";
646 responseString += "<div id=\"login_box\">"; 646 responseString += "<div id=\"login_box\">";
647 647
648 responseString += "<form action=\"/go.cgi\" method=\"GET\" id=\"login-form\">"; 648 responseString += "<form action=\"/go.cgi\" method=\"GET\" id=\"login-form\">";
649 649
650 responseString += "<div id=\"message\">[$errors]</div>"; 650 responseString += "<div id=\"message\">[$errors]</div>";
651 responseString += "<fieldset id=\"firstname\">"; 651 responseString += "<fieldset id=\"firstname\">";
652 responseString += "<legend>First Name:</legend>"; 652 responseString += "<legend>First Name:</legend>";
653 responseString += "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"[$firstname]\" />"; 653 responseString += "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"[$firstname]\" />";
654 responseString += "</fieldset>"; 654 responseString += "</fieldset>";
655 responseString += "<fieldset id=\"lastname\">"; 655 responseString += "<fieldset id=\"lastname\">";
656 responseString += "<legend>Last Name:</legend>"; 656 responseString += "<legend>Last Name:</legend>";
657 responseString += "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"[$lastname]\" />"; 657 responseString += "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"[$lastname]\" />";
658 responseString += "</fieldset>"; 658 responseString += "</fieldset>";
659 responseString += "<fieldset id=\"password\">"; 659 responseString += "<fieldset id=\"password\">";
660 responseString += "<legend>Password:</legend>"; 660 responseString += "<legend>Password:</legend>";
661 responseString += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; 661 responseString += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
662 responseString += "<tr>"; 662 responseString += "<tr>";
663 responseString += "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"[$password]\" /></td>"; 663 responseString += "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"[$password]\" /></td>";
664 responseString += "</tr>"; 664 responseString += "</tr>";
665 responseString += "<tr>"; 665 responseString += "<tr>";
666 responseString += "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" [$remember_password] style=\"margin-left:0px;\"/></td>"; 666 responseString += "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" [$remember_password] style=\"margin-left:0px;\"/></td>";
667 responseString += "<td><label for=\"remember_password\">Remember password</label></td>"; 667 responseString += "<td><label for=\"remember_password\">Remember password</label></td>";
668 responseString += "</tr>"; 668 responseString += "</tr>";
669 responseString += "</table>"; 669 responseString += "</table>";
670 responseString += "</fieldset>"; 670 responseString += "</fieldset>";
671 responseString += "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />"; 671 responseString += "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />";
672 responseString += "<input type=\"hidden\" name=\"method\" value=\"login\" />"; 672 responseString += "<input type=\"hidden\" name=\"method\" value=\"login\" />";
673 responseString += "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"[$grid]\" />"; 673 responseString += "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"[$grid]\" />";
674 responseString += "<input type=\"hidden\" id=\"region\" name=\"region\" value=\"[$region]\" />"; 674 responseString += "<input type=\"hidden\" id=\"region\" name=\"region\" value=\"[$region]\" />";
675 responseString += "<input type=\"hidden\" id=\"location\" name=\"location\" value=\"[$location]\" />"; 675 responseString += "<input type=\"hidden\" id=\"location\" name=\"location\" value=\"[$location]\" />";
676 responseString += "<input type=\"hidden\" id=\"channel\" name=\"channel\" value=\"[$channel]\" />"; 676 responseString += "<input type=\"hidden\" id=\"channel\" name=\"channel\" value=\"[$channel]\" />";
677 responseString += "<input type=\"hidden\" id=\"version\" name=\"version\" value=\"[$version]\" />"; 677 responseString += "<input type=\"hidden\" id=\"version\" name=\"version\" value=\"[$version]\" />";
678 responseString += "<input type=\"hidden\" id=\"lang\" name=\"lang\" value=\"[$lang]\" />"; 678 responseString += "<input type=\"hidden\" id=\"lang\" name=\"lang\" value=\"[$lang]\" />";
679 responseString += "<div id=\"submitbtn\">"; 679 responseString += "<div id=\"submitbtn\">";
680 responseString += "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />"; 680 responseString += "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />";
681 responseString += "</div>"; 681 responseString += "</div>";
682 responseString += "<div id=\"connecting\" style=\"visibility:hidden\"> Connecting...</div>"; 682 responseString += "<div id=\"connecting\" style=\"visibility:hidden\"> Connecting...</div>";
683 683
684 responseString += "<div id=\"helplinks\"><!---"; 684 responseString += "<div id=\"helplinks\"><!---";
685 responseString += "<a href=\"#join now link\" target=\"_blank\"></a> | "; 685 responseString += "<a href=\"#join now link\" target=\"_blank\"></a> | ";
686 responseString += "<a href=\"#forgot password link\" target=\"_blank\"></a>"; 686 responseString += "<a href=\"#forgot password link\" target=\"_blank\"></a>";
687 responseString += "---></div>"; 687 responseString += "---></div>";
688 688
689 responseString += "<div id=\"channelinfo\"> [$channel] | [$version]=[$lang]</div>"; 689 responseString += "<div id=\"channelinfo\"> [$channel] | [$version]=[$lang]</div>";
690 responseString += "</form>"; 690 responseString += "</form>";
691 responseString += "<script language=\"JavaScript\">"; 691 responseString += "<script language=\"JavaScript\">";
692 responseString += "document.getElementById('firstname_input').focus();"; 692 responseString += "document.getElementById('firstname_input').focus();";
693 responseString += "</script>"; 693 responseString += "</script>";
694 responseString += "</div>"; 694 responseString += "</div>";
695 responseString += "</div>"; 695 responseString += "</div>";
696 responseString += "</body>"; 696 responseString += "</body>";
697 responseString += "</html>"; 697 responseString += "</html>";
698 698
699 return responseString; 699 return responseString;
700 } 700 }
701 701
702 /// <summary> 702 /// <summary>
703 /// Saves a target agent to the database 703 /// Saves a target agent to the database
704 /// </summary> 704 /// </summary>
705 /// <param name="profile">The users profile</param> 705 /// <param name="profile">The users profile</param>
706 /// <returns>Successful?</returns> 706 /// <returns>Successful?</returns>
707 public bool CommitAgent(ref UserProfileData profile) 707 public bool CommitAgent(ref UserProfileData profile)
708 { 708 {
709 return m_userManager.CommitAgent(ref profile); 709 return m_userManager.CommitAgent(ref profile);
710 } 710 }
711 711
712 /// <summary> 712 /// <summary>
713 /// Checks a user against it's password hash 713 /// Checks a user against it's password hash
714 /// </summary> 714 /// </summary>
715 /// <param name="profile">The users profile</param> 715 /// <param name="profile">The users profile</param>
716 /// <param name="password">The supplied password</param> 716 /// <param name="password">The supplied password</param>
717 /// <returns>Authenticated?</returns> 717 /// <returns>Authenticated?</returns>
718 public virtual bool AuthenticateUser(UserProfileData profile, string password) 718 public virtual bool AuthenticateUser(UserProfileData profile, string password)
719 { 719 {
720 bool passwordSuccess = false; 720 bool passwordSuccess = false;
721 //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); 721 //m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID);
722 722
723 // Web Login method seems to also occasionally send the hashed password itself 723 // Web Login method seems to also occasionally send the hashed password itself
724 724
725 // we do this to get our hash in a form that the server password code can consume 725 // we do this to get our hash in a form that the server password code can consume
726 // when the web-login-form submits the password in the clear (supposed to be over SSL!) 726 // when the web-login-form submits the password in the clear (supposed to be over SSL!)
727 if (!password.StartsWith("$1$")) 727 if (!password.StartsWith("$1$"))
728 password = "$1$" + Util.Md5Hash(password); 728 password = "$1$" + Util.Md5Hash(password);
729 729
730 password = password.Remove(0, 3); //remove $1$ 730 password = password.Remove(0, 3); //remove $1$
731 731
732 string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); 732 string s = Util.Md5Hash(password + ":" + profile.PasswordSalt);
733 // Testing... 733 // Testing...
734 //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash); 734 //m_log.Info("[LOGIN]: SubHash:" + s + " userprofile:" + profile.passwordHash);
735 //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password); 735 //m_log.Info("[LOGIN]: userprofile:" + profile.passwordHash + " SubCT:" + password);
736 736
737 passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) 737 passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
738 || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); 738 || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase));
739 739
740 return passwordSuccess; 740 return passwordSuccess;
741 } 741 }
742 742
743 public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey) 743 public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey)
744 { 744 {
745 bool passwordSuccess = false; 745 bool passwordSuccess = false;
746 m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID); 746 m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID);
747 747
748 // Match web login key unless it's the default weblogin key UUID.Zero 748 // Match web login key unless it's the default weblogin key UUID.Zero
749 passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero); 749 passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero);
750 750
751 return passwordSuccess; 751 return passwordSuccess;
752 } 752 }
753 753
754 /// <summary> 754 /// <summary>
755 /// 755 ///
756 /// </summary> 756 /// </summary>
757 /// <param name="profile"></param> 757 /// <param name="profile"></param>
758 /// <param name="request"></param> 758 /// <param name="request"></param>
759 public void CreateAgent(UserProfileData profile, XmlRpcRequest request) 759 public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
760 { 760 {
761 m_userManager.CreateAgent(profile, request); 761 m_userManager.CreateAgent(profile, request);
762 } 762 }
763 763
764 public void CreateAgent(UserProfileData profile, OSD request) 764 public void CreateAgent(UserProfileData profile, OSD request)
765 { 765 {
766 m_userManager.CreateAgent(profile, request); 766 m_userManager.CreateAgent(profile, request);
767 } 767 }
768 768
769 /// <summary> 769 /// <summary>
770 /// 770 ///
771 /// </summary> 771 /// </summary>
772 /// <param name="firstname"></param> 772 /// <param name="firstname"></param>
773 /// <param name="lastname"></param> 773 /// <param name="lastname"></param>
774 /// <returns></returns> 774 /// <returns></returns>
775 public virtual UserProfileData GetTheUser(string firstname, string lastname) 775 public virtual UserProfileData GetTheUser(string firstname, string lastname)
776 { 776 {
777 return m_userManager.GetUserProfile(firstname, lastname); 777 return m_userManager.GetUserProfile(firstname, lastname);
778 } 778 }
779 779
780 /// <summary> 780 /// <summary>
781 /// 781 ///
782 /// </summary> 782 /// </summary>
783 /// <returns></returns> 783 /// <returns></returns>
784 public virtual string GetMessage() 784 public virtual string GetMessage()
785 { 785 {
786 return m_welcomeMessage; 786 return m_welcomeMessage;
787 } 787 }
788 788
789 private static LoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL) 789 private static LoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL)
790 { 790 {
791 LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList(); 791 LoginResponse.BuddyList buddylistreturn = new LoginResponse.BuddyList();
792 foreach (FriendListItem fl in LFL) 792 foreach (FriendListItem fl in LFL)
793 { 793 {
794 LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend); 794 LoginResponse.BuddyList.BuddyInfo buddyitem = new LoginResponse.BuddyList.BuddyInfo(fl.Friend);
795 buddyitem.BuddyID = fl.Friend; 795 buddyitem.BuddyID = fl.Friend;
796 buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; 796 buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms;
797 buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; 797 buddyitem.BuddyRightsGiven = (int)fl.FriendPerms;
798 buddylistreturn.AddNewBuddy(buddyitem); 798 buddylistreturn.AddNewBuddy(buddyitem);
799 } 799 }
800 return buddylistreturn; 800 return buddylistreturn;
801 } 801 }
802 802
803 /// <summary> 803 /// <summary>
804 /// Converts the inventory library skeleton into the form required by the rpc request. 804 /// Converts the inventory library skeleton into the form required by the rpc request.
805 /// </summary> 805 /// </summary>
806 /// <returns></returns> 806 /// <returns></returns>
807 protected virtual ArrayList GetInventoryLibrary() 807 protected virtual ArrayList GetInventoryLibrary()
808 { 808 {
809 Dictionary<UUID, InventoryFolderImpl> rootFolders 809 Dictionary<UUID, InventoryFolderImpl> rootFolders
810 = m_libraryRootFolder.RequestSelfAndDescendentFolders(); 810 = m_libraryRootFolder.RequestSelfAndDescendentFolders();
811 ArrayList folderHashes = new ArrayList(); 811 ArrayList folderHashes = new ArrayList();
812 812
813 foreach (InventoryFolderBase folder in rootFolders.Values) 813 foreach (InventoryFolderBase folder in rootFolders.Values)
814 { 814 {
815 Hashtable TempHash = new Hashtable(); 815 Hashtable TempHash = new Hashtable();
816 TempHash["name"] = folder.Name; 816 TempHash["name"] = folder.Name;
817 TempHash["parent_id"] = folder.ParentID.ToString(); 817 TempHash["parent_id"] = folder.ParentID.ToString();
818 TempHash["version"] = (Int32)folder.Version; 818 TempHash["version"] = (Int32)folder.Version;
819 TempHash["type_default"] = (Int32)folder.Type; 819 TempHash["type_default"] = (Int32)folder.Type;
820 TempHash["folder_id"] = folder.ID.ToString(); 820 TempHash["folder_id"] = folder.ID.ToString();
821 folderHashes.Add(TempHash); 821 folderHashes.Add(TempHash);
822 } 822 }
823 823
824 return folderHashes; 824 return folderHashes;
825 } 825 }
826 826
827 /// <summary> 827 /// <summary>
828 /// 828 ///
829 /// </summary> 829 /// </summary>
830 /// <returns></returns> 830 /// <returns></returns>
831 protected virtual ArrayList GetLibraryOwner() 831 protected virtual ArrayList GetLibraryOwner()
832 { 832 {
833 //for now create random inventory library owner 833 //for now create random inventory library owner
834 Hashtable TempHash = new Hashtable(); 834 Hashtable TempHash = new Hashtable();
835 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; 835 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
836 ArrayList inventoryLibOwner = new ArrayList(); 836 ArrayList inventoryLibOwner = new ArrayList();
837 inventoryLibOwner.Add(TempHash); 837 inventoryLibOwner.Add(TempHash);
838 return inventoryLibOwner; 838 return inventoryLibOwner;
839 } 839 }
840 840
841 public class InventoryData 841 public class InventoryData
842 { 842 {
843 public ArrayList InventoryArray = null; 843 public ArrayList InventoryArray = null;
844 public UUID RootFolderID = UUID.Zero; 844 public UUID RootFolderID = UUID.Zero;
845 845
846 public InventoryData(ArrayList invList, UUID rootID) 846 public InventoryData(ArrayList invList, UUID rootID)
847 { 847 {
848 InventoryArray = invList; 848 InventoryArray = invList;
849 RootFolderID = rootID; 849 RootFolderID = rootID;
850 } 850 }
851 } 851 }
852 852
853 protected void SniffLoginKey(Uri uri, Hashtable requestData) 853 protected void SniffLoginKey(Uri uri, Hashtable requestData)
854 { 854 {
855 string uri_str = uri.ToString(); 855 string uri_str = uri.ToString();
856 string[] parts = uri_str.Split(new char[] { '=' }); 856 string[] parts = uri_str.Split(new char[] { '=' });
857 if (parts.Length > 1) 857 if (parts.Length > 1)
858 { 858 {
859 string web_login_key = parts[1]; 859 string web_login_key = parts[1];
860 requestData.Add("web_login_key", web_login_key); 860 requestData.Add("web_login_key", web_login_key);
861 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); 861 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key);
862 } 862 }
863 } 863 }
864 864
865 /// <summary> 865 /// <summary>
866 /// Customises the login response and fills in missing values. This method also tells the login region to 866 /// Customises the login response and fills in missing values. This method also tells the login region to
867 /// expect a client connection. 867 /// expect a client connection.
868 /// </summary> 868 /// </summary>
869 /// <param name="response">The existing response</param> 869 /// <param name="response">The existing response</param>
870 /// <param name="theUser">The user profile</param> 870 /// <param name="theUser">The user profile</param>
871 /// <param name="startLocationRequest">The requested start location</param> 871 /// <param name="startLocationRequest">The requested start location</param>
872 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns> 872 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
873 public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) 873 public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
874 { 874 {
875 // add active gestures to login-response 875 // add active gestures to login-response
876 AddActiveGestures(response, theUser); 876 AddActiveGestures(response, theUser);
877 877
878 // HomeLocation 878 // HomeLocation
879 RegionInfo homeInfo = null; 879 RegionInfo homeInfo = null;
880 880
881 // use the homeRegionID if it is stored already. If not, use the regionHandle as before 881 // use the homeRegionID if it is stored already. If not, use the regionHandle as before
882 UUID homeRegionId = theUser.HomeRegionID; 882 UUID homeRegionId = theUser.HomeRegionID;
883 ulong homeRegionHandle = theUser.HomeRegion; 883 ulong homeRegionHandle = theUser.HomeRegion;
884 if (homeRegionId != UUID.Zero) 884 if (homeRegionId != UUID.Zero)
885 { 885 {
886 homeInfo = GetRegionInfo(homeRegionId); 886 homeInfo = GetRegionInfo(homeRegionId);
887 } 887 }
888 else 888 else
889 { 889 {
890 homeInfo = GetRegionInfo(homeRegionHandle); 890 homeInfo = GetRegionInfo(homeRegionHandle);
891 } 891 }
892 892
893 if (homeInfo != null) 893 if (homeInfo != null)
894 { 894 {
895 response.Home = 895 response.Home =
896 string.Format( 896 string.Format(
897 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 897 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
898 (homeInfo.RegionLocX * Constants.RegionSize), 898 (homeInfo.RegionLocX * Constants.RegionSize),
899 (homeInfo.RegionLocY * Constants.RegionSize), 899 (homeInfo.RegionLocY * Constants.RegionSize),
900 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, 900 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
901 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); 901 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
902 } 902 }
903 else 903 else
904 { 904 {
905 m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); 905 m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY);
906 // Emergency mode: Home-region isn't available, so we can't request the region info. 906 // Emergency mode: Home-region isn't available, so we can't request the region info.
907 // Use the stored home regionHandle instead. 907 // Use the stored home regionHandle instead.
908 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again 908 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
909 ulong regionX = homeRegionHandle >> 32; 909 ulong regionX = homeRegionHandle >> 32;
910 ulong regionY = homeRegionHandle & 0xffffffff; 910 ulong regionY = homeRegionHandle & 0xffffffff;
911 response.Home = 911 response.Home =
912 string.Format( 912 string.Format(
913 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 913 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
914 regionX, regionY, 914 regionX, regionY,
915 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, 915 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
916 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); 916 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
917 917
918 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", 918 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
919 theUser.FirstName, theUser.SurName, 919 theUser.FirstName, theUser.SurName,
920 regionX, regionY); 920 regionX, regionY);
921 } 921 }
922 922
923 // StartLocation 923 // StartLocation
924 RegionInfo regionInfo = null; 924 RegionInfo regionInfo = null;
925 if (startLocationRequest == "home") 925 if (startLocationRequest == "home")
926 { 926 {
927 regionInfo = homeInfo; 927 regionInfo = homeInfo;
928 theUser.CurrentAgent.Position = theUser.HomeLocation; 928 theUser.CurrentAgent.Position = theUser.HomeLocation;
929 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; 929 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]";
930 } 930 }
931 else if (startLocationRequest == "last") 931 else if (startLocationRequest == "last")
932 { 932 {
933 UUID lastRegion = theUser.CurrentAgent.Region; 933 UUID lastRegion = theUser.CurrentAgent.Region;
934 regionInfo = GetRegionInfo(lastRegion); 934 regionInfo = GetRegionInfo(lastRegion);
935 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; 935 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]";
936 } 936 }
937 else 937 else
938 { 938 {
939 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); 939 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
940 Match uriMatch = reURI.Match(startLocationRequest); 940 Match uriMatch = reURI.Match(startLocationRequest);
941 if (uriMatch == null) 941 if (uriMatch == null)
942 { 942 {
943 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); 943 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest);
944 } 944 }
945 else 945 else
946 { 946 {
947 string region = uriMatch.Groups["region"].ToString(); 947 string region = uriMatch.Groups["region"].ToString();
948 regionInfo = RequestClosestRegion(region); 948 regionInfo = RequestClosestRegion(region);
949 if (regionInfo == null) 949 if (regionInfo == null)
950 { 950 {
951 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); 951 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region);
952 } 952 }
953 else 953 else
954 { 954 {
955 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), 955 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
956 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); 956 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
957 } 957 }
958 } 958 }
959 response.LookAt = "[r0,r1,r0]"; 959 response.LookAt = "[r0,r1,r0]";
960 // can be: last, home, safe, url 960 // can be: last, home, safe, url
961 response.StartLocation = "url"; 961 response.StartLocation = "url";
962 } 962 }
963 963
964 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) 964 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response)))
965 { 965 {
966 return true; 966 return true;
967 } 967 }
968 968
969 // StartLocation not available, send him to a nearby region instead 969 // StartLocation not available, send him to a nearby region instead
970 // regionInfo = m_gridService.RequestClosestRegion(""); 970 // regionInfo = m_gridService.RequestClosestRegion("");
971 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); 971 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
972 972
973 // Send him to default region instead 973 // Send him to default region instead
974 ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | 974 ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) |
975 ((ulong)m_defaultHomeY * Constants.RegionSize); 975 ((ulong)m_defaultHomeY * Constants.RegionSize);
976 976
977 if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) 977 if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle))
978 { 978 {
979 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); 979 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
980 return false; 980 return false;
981 } 981 }
982 982
983 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); 983 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
984 regionInfo = GetRegionInfo(defaultHandle); 984 regionInfo = GetRegionInfo(defaultHandle);
985 985
986 if (regionInfo == null) 986 if (regionInfo == null)
987 { 987 {
988 m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); 988 m_log.ErrorFormat("[LOGIN]: No default region available. Aborting.");
989 return false; 989 return false;
990 } 990 }
991 991
992 theUser.CurrentAgent.Position = new Vector3(128, 128, 0); 992 theUser.CurrentAgent.Position = new Vector3(128, 128, 0);
993 response.StartLocation = "safe"; 993 response.StartLocation = "safe";
994 994
995 return PrepareLoginToRegion(regionInfo, theUser, response); 995 return PrepareLoginToRegion(regionInfo, theUser, response);
996 } 996 }
997 997
998 protected abstract RegionInfo RequestClosestRegion(string region); 998 protected abstract RegionInfo RequestClosestRegion(string region);
999 protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle); 999 protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle);
1000 protected abstract RegionInfo GetRegionInfo(UUID homeRegionId); 1000 protected abstract RegionInfo GetRegionInfo(UUID homeRegionId);
1001 protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response); 1001 protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response);
1002 1002
1003 /// <summary> 1003 /// <summary>
1004 /// Add active gestures of the user to the login response. 1004 /// Add active gestures of the user to the login response.
1005 /// </summary> 1005 /// </summary>
1006 /// <param name="response"> 1006 /// <param name="response">
1007 /// A <see cref="LoginResponse"/> 1007 /// A <see cref="LoginResponse"/>
1008 /// </param> 1008 /// </param>
1009 /// <param name="theUser"> 1009 /// <param name="theUser">
1010 /// A <see cref="UserProfileData"/> 1010 /// A <see cref="UserProfileData"/>
1011 /// </param> 1011 /// </param>
1012 protected void AddActiveGestures(LoginResponse response, UserProfileData theUser) 1012 protected void AddActiveGestures(LoginResponse response, UserProfileData theUser)
1013 { 1013 {
1014 List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID); 1014 List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID);
1015 //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); 1015 //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count);
1016 ArrayList list = new ArrayList(); 1016 ArrayList list = new ArrayList();
1017 if (gestures != null) 1017 if (gestures != null)
1018 { 1018 {
1019 foreach (InventoryItemBase gesture in gestures) 1019 foreach (InventoryItemBase gesture in gestures)
1020 { 1020 {
1021 Hashtable item = new Hashtable(); 1021 Hashtable item = new Hashtable();
1022 item["item_id"] = gesture.ID.ToString(); 1022 item["item_id"] = gesture.ID.ToString();
1023 item["asset_id"] = gesture.AssetID.ToString(); 1023 item["asset_id"] = gesture.AssetID.ToString();
1024 list.Add(item); 1024 list.Add(item);
1025 } 1025 }
1026 } 1026 }
1027 response.ActiveGestures = list; 1027 response.ActiveGestures = list;
1028 } 1028 }
1029 1029
1030 /// <summary> 1030 /// <summary>
1031 /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. 1031 /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user.
1032 /// </summary> 1032 /// </summary>
1033 /// <param name="userID"></param> 1033 /// <param name="userID"></param>
1034 /// <returns></returns> 1034 /// <returns></returns>
1035 /// <exception cref='System.Exception'>This will be thrown if there is a problem with the inventory service</exception> 1035 /// <exception cref='System.Exception'>This will be thrown if there is a problem with the inventory service</exception>
1036 protected InventoryData GetInventorySkeleton(UUID userID) 1036 protected InventoryData GetInventorySkeleton(UUID userID)
1037 { 1037 {
1038 List<InventoryFolderBase> folders = m_inventoryService.GetInventorySkeleton(userID); 1038 List<InventoryFolderBase> folders = m_inventoryService.GetInventorySkeleton(userID);
1039 1039
1040 // If we have user auth but no inventory folders for some reason, create a new set of folders. 1040 // If we have user auth but no inventory folders for some reason, create a new set of folders.
1041 if (folders == null || folders.Count == 0) 1041 if (folders == null || folders.Count == 0)
1042 { 1042 {
1043 m_log.InfoFormat( 1043 m_log.InfoFormat(
1044 "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); 1044 "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID);
1045 1045
1046 // Although the create user function creates a new agent inventory along with a new user profile, some 1046 // Although the create user function creates a new agent inventory along with a new user profile, some
1047 // tools are creating the user profile directly in the database without creating the inventory. At 1047 // tools are creating the user profile directly in the database without creating the inventory. At
1048 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already 1048 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
1049 // exist. 1049 // exist.
1050 if (!m_inventoryService.CreateNewUserInventory(userID)) 1050 if (!m_inventoryService.CreateNewUserInventory(userID))
1051 { 1051 {
1052 throw new Exception( 1052 throw new Exception(
1053 String.Format( 1053 String.Format(
1054 "The inventory creation request for user {0} did not succeed." 1054 "The inventory creation request for user {0} did not succeed."
1055 + " Please contact your inventory service provider for more information.", 1055 + " Please contact your inventory service provider for more information.",
1056 userID)); 1056 userID));
1057 } 1057 }
1058 1058
1059 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); 1059 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
1060 1060
1061 folders = m_inventoryService.GetInventorySkeleton(userID); 1061 folders = m_inventoryService.GetInventorySkeleton(userID);
1062 1062
1063 if (folders == null || folders.Count == 0) 1063 if (folders == null || folders.Count == 0)
1064 { 1064 {
1065 throw new Exception( 1065 throw new Exception(
1066 String.Format( 1066 String.Format(
1067 "A root inventory folder for user {0} could not be retrieved from the inventory service", 1067 "A root inventory folder for user {0} could not be retrieved from the inventory service",
1068 userID)); 1068 userID));
1069 } 1069 }
1070 } 1070 }
1071 1071
1072 UUID rootID = UUID.Zero; 1072 UUID rootID = UUID.Zero;
1073 ArrayList AgentInventoryArray = new ArrayList(); 1073 ArrayList AgentInventoryArray = new ArrayList();
1074 Hashtable TempHash; 1074 Hashtable TempHash;
1075 foreach (InventoryFolderBase InvFolder in folders) 1075 foreach (InventoryFolderBase InvFolder in folders)
1076 { 1076 {
1077 if (InvFolder.ParentID == UUID.Zero) 1077 if (InvFolder.ParentID == UUID.Zero)
1078 { 1078 {
1079 rootID = InvFolder.ID; 1079 rootID = InvFolder.ID;
1080 } 1080 }
1081 TempHash = new Hashtable(); 1081 TempHash = new Hashtable();
1082 TempHash["name"] = InvFolder.Name; 1082 TempHash["name"] = InvFolder.Name;
1083 TempHash["parent_id"] = InvFolder.ParentID.ToString(); 1083 TempHash["parent_id"] = InvFolder.ParentID.ToString();
1084 TempHash["version"] = (Int32)InvFolder.Version; 1084 TempHash["version"] = (Int32)InvFolder.Version;
1085 TempHash["type_default"] = (Int32)InvFolder.Type; 1085 TempHash["type_default"] = (Int32)InvFolder.Type;
1086 TempHash["folder_id"] = InvFolder.ID.ToString(); 1086 TempHash["folder_id"] = InvFolder.ID.ToString();
1087 AgentInventoryArray.Add(TempHash); 1087 AgentInventoryArray.Add(TempHash);
1088 } 1088 }
1089 1089
1090 return new InventoryData(AgentInventoryArray, rootID); 1090 return new InventoryData(AgentInventoryArray, rootID);
1091 } 1091 }
1092 } 1092 }
1093} 1093}
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs
index a910136..4811434 100644
--- a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs
@@ -1,224 +1,224 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text.RegularExpressions; 32using System.Text.RegularExpressions;
33using log4net; 33using log4net;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39using OpenSim.Framework.Communications.Services;
40using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Communications.Capabilities; 41using OpenSim.Framework.Communications.Capabilities;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43 43
44namespace OpenSim.Grid.UserServer.Modules 44namespace OpenSim.Grid.UserServer.Modules
45{ 45{
46 46
47 /// <summary> 47 /// <summary>
48 /// Hypergrid login service used in grid mode. 48 /// Hypergrid login service used in grid mode.
49 /// </summary> 49 /// </summary>
50 public class UserLoginAuthService : HGLoginAuthService 50 public class UserLoginAuthService : HGLoginAuthService
51 { 51 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public UserConfig m_config; 54 public UserConfig m_config;
55 private readonly IRegionProfileRouter m_regionProfileService; 55 private readonly IRegionProfileRouter m_regionProfileService;
56 56
57 protected BaseHttpServer m_httpServer; 57 protected BaseHttpServer m_httpServer;
58 58
59 public UserLoginAuthService( 59 public UserLoginAuthService(
60 UserManagerBase userManager, IInterServiceInventoryServices inventoryService, 60 UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
61 LibraryRootFolder libraryRootFolder, 61 LibraryRootFolder libraryRootFolder,
62 UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) 62 UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService)
63 : base(userManager, welcomeMess, inventoryService, null, true, libraryRootFolder, null) 63 : base(userManager, welcomeMess, inventoryService, null, true, libraryRootFolder, null)
64 { 64 {
65 m_config = config; 65 m_config = config;
66 m_defaultHomeX = m_config.DefaultX; 66 m_defaultHomeX = m_config.DefaultX;
67 m_defaultHomeY = m_config.DefaultY; 67 m_defaultHomeY = m_config.DefaultY;
68 m_inventoryService = inventoryService; 68 m_inventoryService = inventoryService;
69 m_regionProfileService = regionProfileService; 69 m_regionProfileService = regionProfileService;
70 70
71 NetworkServersInfo serversinfo = new NetworkServersInfo(1000, 1000); 71 NetworkServersInfo serversinfo = new NetworkServersInfo(1000, 1000);
72 serversinfo.GridRecvKey = m_config.GridRecvKey; 72 serversinfo.GridRecvKey = m_config.GridRecvKey;
73 serversinfo.GridSendKey = m_config.GridSendKey; 73 serversinfo.GridSendKey = m_config.GridSendKey;
74 serversinfo.GridURL = m_config.GridServerURL.ToString(); 74 serversinfo.GridURL = m_config.GridServerURL.ToString();
75 serversinfo.InventoryURL = m_config.InventoryUrl.ToString(); 75 serversinfo.InventoryURL = m_config.InventoryUrl.ToString();
76 serversinfo.UserURL = m_config.AuthUrl.ToString(); 76 serversinfo.UserURL = m_config.AuthUrl.ToString();
77 SetServersInfo(serversinfo); 77 SetServersInfo(serversinfo);
78 } 78 }
79 79
80 public void RegisterHandlers(BaseHttpServer httpServer) 80 public void RegisterHandlers(BaseHttpServer httpServer)
81 { 81 {
82 m_httpServer = httpServer; 82 m_httpServer = httpServer;
83 83
84 httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod); 84 httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod);
85 httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod); 85 httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod);
86 httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod); 86 httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod);
87 } 87 }
88 88
89 89
90 public override void LogOffUser(UserProfileData theUser, string message) 90 public override void LogOffUser(UserProfileData theUser, string message)
91 { 91 {
92 RegionProfileData SimInfo; 92 RegionProfileData SimInfo;
93 try 93 try
94 { 94 {
95 SimInfo = m_regionProfileService.RequestSimProfileData( 95 SimInfo = m_regionProfileService.RequestSimProfileData(
96 theUser.CurrentAgent.Handle, m_config.GridServerURL, 96 theUser.CurrentAgent.Handle, m_config.GridServerURL,
97 m_config.GridSendKey, m_config.GridRecvKey); 97 m_config.GridSendKey, m_config.GridRecvKey);
98 98
99 if (SimInfo == null) 99 if (SimInfo == null)
100 { 100 {
101 m_log.Error("[GRID]: Region user was in isn't currently logged in"); 101 m_log.Error("[GRID]: Region user was in isn't currently logged in");
102 return; 102 return;
103 } 103 }
104 } 104 }
105 catch (Exception) 105 catch (Exception)
106 { 106 {
107 m_log.Error("[GRID]: Unable to look up region to log user off"); 107 m_log.Error("[GRID]: Unable to look up region to log user off");
108 return; 108 return;
109 } 109 }
110 110
111 // Prepare notification 111 // Prepare notification
112 Hashtable SimParams = new Hashtable(); 112 Hashtable SimParams = new Hashtable();
113 SimParams["agent_id"] = theUser.ID.ToString(); 113 SimParams["agent_id"] = theUser.ID.ToString();
114 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); 114 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
115 SimParams["region_secret2"] = SimInfo.regionSecret; 115 SimParams["region_secret2"] = SimInfo.regionSecret;
116 //m_log.Info(SimInfo.regionSecret); 116 //m_log.Info(SimInfo.regionSecret);
117 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); 117 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
118 SimParams["message"] = message; 118 SimParams["message"] = message;
119 ArrayList SendParams = new ArrayList(); 119 ArrayList SendParams = new ArrayList();
120 SendParams.Add(SimParams); 120 SendParams.Add(SimParams);
121 121
122 m_log.InfoFormat( 122 m_log.InfoFormat(
123 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", 123 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
124 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, 124 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
125 theUser.FirstName + " " + theUser.SurName); 125 theUser.FirstName + " " + theUser.SurName);
126 126
127 try 127 try
128 { 128 {
129 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); 129 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
130 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 130 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
131 131
132 if (GridResp.IsFault) 132 if (GridResp.IsFault)
133 { 133 {
134 m_log.ErrorFormat( 134 m_log.ErrorFormat(
135 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", 135 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
136 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 136 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
137 } 137 }
138 } 138 }
139 catch (Exception) 139 catch (Exception)
140 { 140 {
141 m_log.Error("[LOGIN]: Error telling region to logout user!"); 141 m_log.Error("[LOGIN]: Error telling region to logout user!");
142 } 142 }
143 143
144 // Prepare notification 144 // Prepare notification
145 SimParams = new Hashtable(); 145 SimParams = new Hashtable();
146 SimParams["agent_id"] = theUser.ID.ToString(); 146 SimParams["agent_id"] = theUser.ID.ToString();
147 SimParams["region_secret"] = SimInfo.regionSecret; 147 SimParams["region_secret"] = SimInfo.regionSecret;
148 //m_log.Info(SimInfo.regionSecret); 148 //m_log.Info(SimInfo.regionSecret);
149 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); 149 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
150 SimParams["message"] = message; 150 SimParams["message"] = message;
151 SendParams = new ArrayList(); 151 SendParams = new ArrayList();
152 SendParams.Add(SimParams); 152 SendParams.Add(SimParams);
153 153
154 m_log.InfoFormat( 154 m_log.InfoFormat(
155 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", 155 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
156 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, 156 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
157 theUser.FirstName + " " + theUser.SurName); 157 theUser.FirstName + " " + theUser.SurName);
158 158
159 try 159 try
160 { 160 {
161 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); 161 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
162 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 162 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
163 163
164 if (GridResp.IsFault) 164 if (GridResp.IsFault)
165 { 165 {
166 m_log.ErrorFormat( 166 m_log.ErrorFormat(
167 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", 167 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
168 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 168 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
169 } 169 }
170 } 170 }
171 catch (Exception) 171 catch (Exception)
172 { 172 {
173 m_log.Error("[LOGIN]: Error telling region to logout user!"); 173 m_log.Error("[LOGIN]: Error telling region to logout user!");
174 } 174 }
175 //base.LogOffUser(theUser); 175 //base.LogOffUser(theUser);
176 } 176 }
177 177
178 protected override RegionInfo RequestClosestRegion(string region) 178 protected override RegionInfo RequestClosestRegion(string region)
179 { 179 {
180 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, 180 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region,
181 m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); 181 m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
182 182
183 if (profileData != null) 183 if (profileData != null)
184 { 184 {
185 return profileData.ToRegionInfo(); 185 return profileData.ToRegionInfo();
186 } 186 }
187 else 187 else
188 { 188 {
189 return null; 189 return null;
190 } 190 }
191 } 191 }
192 192
193 protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) 193 protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
194 { 194 {
195 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, 195 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle,
196 m_config.GridServerURL, m_config.GridSendKey, 196 m_config.GridServerURL, m_config.GridSendKey,
197 m_config.GridRecvKey); 197 m_config.GridRecvKey);
198 if (profileData != null) 198 if (profileData != null)
199 { 199 {
200 return profileData.ToRegionInfo(); 200 return profileData.ToRegionInfo();
201 } 201 }
202 else 202 else
203 { 203 {
204 return null; 204 return null;
205 } 205 }
206 } 206 }
207 207
208 protected override RegionInfo GetRegionInfo(UUID homeRegionId) 208 protected override RegionInfo GetRegionInfo(UUID homeRegionId)
209 { 209 {
210 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, 210 RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId,
211 m_config.GridServerURL, m_config.GridSendKey, 211 m_config.GridServerURL, m_config.GridSendKey,
212 m_config.GridRecvKey); 212 m_config.GridRecvKey);
213 if (profileData != null) 213 if (profileData != null)
214 { 214 {
215 return profileData.ToRegionInfo(); 215 return profileData.ToRegionInfo();
216 } 216 }
217 else 217 else
218 { 218 {
219 return null; 219 return null;
220 } 220 }
221 } 221 }
222 222
223 } 223 }
224} 224}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 56eb508..a521ead 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
184 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 184 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
185 "POST", m_RestURL+"/SaveMessage/", im); 185 "POST", m_RestURL+"/SaveMessage/", im);
186 186
187 if(im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 187 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
188 { 188 {
189 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 189 IClientAPI client = FindClient(new UUID(im.fromAgentID));
190 if (client == null) 190 if (client == null)
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
index 525dda7..a1306cd 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs
@@ -1,165 +1,165 @@
1/** 1/**
2 * Copyright (c) 2008, Contributors. All rights reserved. 2 * Copyright (c) 2008, Contributors. All rights reserved.
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without modification, 5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met: 6 * are permitted provided that the following conditions are met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright notice, 8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice, 10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * * Neither the name of the Organizations nor the names of Individual 13 * * Neither the name of the Organizations nor the names of Individual
14 * Contributors may be used to endorse or promote products derived from 14 * Contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission. 15 * this software without specific prior written permission.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25 * OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28 28
29using System; 29using System;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using log4net; 33using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Services; 40using OpenSim.Framework.Communications.Services;
41using Caps = OpenSim.Framework.Communications.Capabilities.Caps; 41using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
42using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; 42using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers;
43using OpenSim.Framework.Servers; 43using OpenSim.Framework.Servers;
44using OpenSim.Framework.Servers.Interfaces; 44using OpenSim.Framework.Servers.Interfaces;
45using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.CoreModules.Communications.REST; 47using OpenSim.Region.CoreModules.Communications.REST;
48 48
49using OpenMetaverse.StructuredData; 49using OpenMetaverse.StructuredData;
50 50
51namespace OpenSim.Region.CoreModules.Hypergrid 51namespace OpenSim.Region.CoreModules.Hypergrid
52{ 52{
53 public class HGStandaloneInventoryModule : IRegionModule 53 public class HGStandaloneInventoryModule : IRegionModule
54 { 54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 private static bool initialized = false; 56 private static bool initialized = false;
57 private static bool enabled = false; 57 private static bool enabled = false;
58 58
59 private bool m_doLookup = false; 59 private bool m_doLookup = false;
60 Scene m_scene; 60 Scene m_scene;
61 HGInventoryService m_inventoryService; 61 HGInventoryService m_inventoryService;
62 InventoryServiceBase m_inventoryBase; 62 InventoryServiceBase m_inventoryBase;
63 63
64 public bool DoLookup 64 public bool DoLookup
65 { 65 {
66 get { return m_doLookup; } 66 get { return m_doLookup; }
67 set { m_doLookup = value; } 67 set { m_doLookup = value; }
68 } 68 }
69 69
70 #region IRegionModule interface 70 #region IRegionModule interface
71 71
72 public void Initialise(Scene scene, IConfigSource config) 72 public void Initialise(Scene scene, IConfigSource config)
73 { 73 {
74 if (!initialized) 74 if (!initialized)
75 { 75 {
76 initialized = true; 76 initialized = true;
77 m_scene = scene; 77 m_scene = scene;
78 78
79 // This module is only on for standalones 79 // This module is only on for standalones
80 enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); 80 enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false);
81 } 81 }
82 } 82 }
83 83
84 public void PostInitialise() 84 public void PostInitialise()
85 { 85 {
86 if (enabled) 86 if (enabled)
87 { 87 {
88 m_log.Info("[HGStandaloneInvModule]: Starting..."); 88 m_log.Info("[HGStandaloneInvModule]: Starting...");
89 //m_inventoryService = new InventoryService(m_scene); 89 //m_inventoryService = new InventoryService(m_scene);
90 m_inventoryBase = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; 90 m_inventoryBase = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService;
91 91
92 m_inventoryService = new HGInventoryService(m_inventoryBase, 92 m_inventoryService = new HGInventoryService(m_inventoryBase,
93 ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin, 93 ((AssetServerBase)m_scene.CommsManager.AssetCache.AssetServer).AssetProviderPlugin,
94 (UserManagerBase)m_scene.CommsManager.UserService, m_scene.CommsManager.HttpServer, 94 (UserManagerBase)m_scene.CommsManager.UserService, m_scene.CommsManager.HttpServer,
95 m_scene.CommsManager.NetworkServersInfo.InventoryURL); 95 m_scene.CommsManager.NetworkServersInfo.InventoryURL);
96 96
97 AddHttpHandlers(m_scene.CommsManager.HttpServer); 97 AddHttpHandlers(m_scene.CommsManager.HttpServer);
98 m_inventoryService.AddHttpHandlers(); 98 m_inventoryService.AddHttpHandlers();
99 } 99 }
100 } 100 }
101 101
102 public void Close() 102 public void Close()
103 { 103 {
104 } 104 }
105 105
106 public string Name 106 public string Name
107 { 107 {
108 get { return "HGStandaloneInventoryModule"; } 108 get { return "HGStandaloneInventoryModule"; }
109 } 109 }
110 110
111 public bool IsSharedModule 111 public bool IsSharedModule
112 { 112 {
113 get { return true; } 113 get { return true; }
114 } 114 }
115 115
116 #endregion 116 #endregion
117 117
118 public virtual void AddHttpHandlers(IHttpServer httpServer) 118 public virtual void AddHttpHandlers(IHttpServer httpServer)
119 { 119 {
120 120
121 httpServer.AddStreamHandler( 121 httpServer.AddStreamHandler(
122 new RestDeserialiseSecureHandler<Guid, InventoryCollection>( 122 new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
123 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); 123 "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession));
124 124
125 httpServer.AddStreamHandler( 125 httpServer.AddStreamHandler(
126 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 126 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
127 "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession)); 127 "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession));
128 128
129 httpServer.AddStreamHandler( 129 httpServer.AddStreamHandler(
130 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 130 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
131 "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession)); 131 "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession));
132 132
133 httpServer.AddStreamHandler( 133 httpServer.AddStreamHandler(
134 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 134 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
135 "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession)); 135 "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession));
136 136
137 httpServer.AddStreamHandler( 137 httpServer.AddStreamHandler(
138 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 138 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
139 "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession)); 139 "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession));
140 140
141 httpServer.AddStreamHandler( 141 httpServer.AddStreamHandler(
142 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 142 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
143 "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession)); 143 "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession));
144 144
145 httpServer.AddStreamHandler( 145 httpServer.AddStreamHandler(
146 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 146 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
147 "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession)); 147 "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession));
148 148
149 } 149 }
150 150
151 /// <summary> 151 /// <summary>
152 /// Check that the source of an inventory request for a particular agent is a current session belonging to 152 /// Check that the source of an inventory request for a particular agent is a current session belonging to
153 /// that agent. 153 /// that agent.
154 /// </summary> 154 /// </summary>
155 /// <param name="session_id"></param> 155 /// <param name="session_id"></param>
156 /// <param name="avatar_id"></param> 156 /// <param name="avatar_id"></param>
157 /// <returns></returns> 157 /// <returns></returns>
158 public bool CheckAuthSession(string session_id, string avatar_id) 158 public bool CheckAuthSession(string session_id, string avatar_id)
159 { 159 {
160 return true; 160 return true;
161 } 161 }
162 162
163 } 163 }
164 164
165} 165}
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
index 9e134be..f0e957b 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
@@ -1,253 +1,253 @@
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 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39using OpenSim.Framework.Communications.Services;
40using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Communications.Capabilities; 41using OpenSim.Framework.Communications.Capabilities;
42using OpenSim.Framework.Servers.Interfaces; 42using OpenSim.Framework.Servers.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45 45
46namespace OpenSim.Region.CoreModules.Hypergrid 46namespace OpenSim.Region.CoreModules.Hypergrid
47{ 47{
48 public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector 48 public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector
49 { 49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 protected List<Scene> m_scenes = new List<Scene>(); 52 protected List<Scene> m_scenes = new List<Scene>();
53 protected Scene m_firstScene; 53 protected Scene m_firstScene;
54 54
55 protected bool m_enabled = false; // Module is only enabled if running in standalone mode 55 protected bool m_enabled = false; // Module is only enabled if running in standalone mode
56 56
57 57
58 public bool RegionLoginsEnabled 58 public bool RegionLoginsEnabled
59 { 59 {
60 get 60 get
61 { 61 {
62 if (m_firstScene != null) 62 if (m_firstScene != null)
63 { 63 {
64 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 64 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled;
65 } 65 }
66 else 66 else
67 { 67 {
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 } 71 }
72 72
73 protected HGLoginAuthService m_loginService; 73 protected HGLoginAuthService m_loginService;
74 74
75 #region IRegionModule Members 75 #region IRegionModule Members
76 76
77 public void Initialise(Scene scene, IConfigSource source) 77 public void Initialise(Scene scene, IConfigSource source)
78 { 78 {
79 if (m_firstScene == null) 79 if (m_firstScene == null)
80 { 80 {
81 m_firstScene = scene; 81 m_firstScene = scene;
82 82
83 IConfig startupConfig = source.Configs["Startup"]; 83 IConfig startupConfig = source.Configs["Startup"];
84 if (startupConfig != null) 84 if (startupConfig != null)
85 { 85 {
86 m_enabled = !startupConfig.GetBoolean("gridmode", false); 86 m_enabled = !startupConfig.GetBoolean("gridmode", false);
87 } 87 }
88 88
89 if (m_enabled) 89 if (m_enabled)
90 { 90 {
91 m_log.Debug("[HGLogin] HGlogin module enabled"); 91 m_log.Debug("[HGLogin] HGlogin module enabled");
92 bool authenticate = true; 92 bool authenticate = true;
93 string welcomeMessage = "Welcome to OpenSim"; 93 string welcomeMessage = "Welcome to OpenSim";
94 IConfig standaloneConfig = source.Configs["StandAlone"]; 94 IConfig standaloneConfig = source.Configs["StandAlone"];
95 if (standaloneConfig != null) 95 if (standaloneConfig != null)
96 { 96 {
97 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); 97 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
98 welcomeMessage = standaloneConfig.GetString("welcome_message"); 98 welcomeMessage = standaloneConfig.GetString("welcome_message");
99 } 99 }
100 100
101 //TODO: fix casting. 101 //TODO: fix casting.
102 LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; 102 LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
103 103
104 IHttpServer httpServer = m_firstScene.CommsManager.HttpServer; 104 IHttpServer httpServer = m_firstScene.CommsManager.HttpServer;
105 105
106 //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference 106 //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference
107 m_loginService = new HGLoginAuthService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this); 107 m_loginService = new HGLoginAuthService((UserManagerBase)m_firstScene.CommsManager.UserService, welcomeMessage, m_firstScene.CommsManager.InterServiceInventoryService, m_firstScene.CommsManager.NetworkServersInfo, authenticate, rootFolder, this);
108 108
109 httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod); 109 httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod);
110 httpServer.AddXmlRPCHandler("hg_new_auth_key", m_loginService.XmlRpcGenerateKeyMethod); 110 httpServer.AddXmlRPCHandler("hg_new_auth_key", m_loginService.XmlRpcGenerateKeyMethod);
111 httpServer.AddXmlRPCHandler("hg_verify_auth_key", m_loginService.XmlRpcVerifyKeyMethod); 111 httpServer.AddXmlRPCHandler("hg_verify_auth_key", m_loginService.XmlRpcVerifyKeyMethod);
112 112
113 } 113 }
114 } 114 }
115 115
116 if (m_enabled) 116 if (m_enabled)
117 { 117 {
118 AddScene(scene); 118 AddScene(scene);
119 } 119 }
120 } 120 }
121 121
122 public void PostInitialise() 122 public void PostInitialise()
123 { 123 {
124 124
125 } 125 }
126 126
127 public void Close() 127 public void Close()
128 { 128 {
129 129
130 } 130 }
131 131
132 public string Name 132 public string Name
133 { 133 {
134 get { return "HGStandaloneLoginModule"; } 134 get { return "HGStandaloneLoginModule"; }
135 } 135 }
136 136
137 public bool IsSharedModule 137 public bool IsSharedModule
138 { 138 {
139 get { return true; } 139 get { return true; }
140 } 140 }
141 141
142 #endregion 142 #endregion
143 143
144 protected void AddScene(Scene scene) 144 protected void AddScene(Scene scene)
145 { 145 {
146 lock (m_scenes) 146 lock (m_scenes)
147 { 147 {
148 if (!m_scenes.Contains(scene)) 148 if (!m_scenes.Contains(scene))
149 { 149 {
150 m_scenes.Add(scene); 150 m_scenes.Add(scene);
151 } 151 }
152 } 152 }
153 } 153 }
154 154
155 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent) 155 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent)
156 { 156 {
157 return true; 157 return true;
158 } 158 }
159 159
160 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) 160 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
161 { 161 {
162 Scene scene; 162 Scene scene;
163 if (TryGetRegion(regionHandle, out scene)) 163 if (TryGetRegion(regionHandle, out scene))
164 { 164 {
165 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); 165 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
166 } 166 }
167 } 167 }
168 168
169 public RegionInfo RequestNeighbourInfo(ulong regionhandle) 169 public RegionInfo RequestNeighbourInfo(ulong regionhandle)
170 { 170 {
171 Scene scene; 171 Scene scene;
172 if (TryGetRegion(regionhandle, out scene)) 172 if (TryGetRegion(regionhandle, out scene))
173 { 173 {
174 return scene.RegionInfo; 174 return scene.RegionInfo;
175 } 175 }
176 return null; 176 return null;
177 } 177 }
178 178
179 public RegionInfo RequestClosestRegion(string region) 179 public RegionInfo RequestClosestRegion(string region)
180 { 180 {
181 Scene scene; 181 Scene scene;
182 if (TryGetRegion(region, out scene)) 182 if (TryGetRegion(region, out scene))
183 { 183 {
184 return scene.RegionInfo; 184 return scene.RegionInfo;
185 } 185 }
186 return null; 186 return null;
187 } 187 }
188 188
189 public RegionInfo RequestNeighbourInfo(UUID regionID) 189 public RegionInfo RequestNeighbourInfo(UUID regionID)
190 { 190 {
191 Scene scene; 191 Scene scene;
192 if (TryGetRegion(regionID, out scene)) 192 if (TryGetRegion(regionID, out scene))
193 { 193 {
194 return scene.RegionInfo; 194 return scene.RegionInfo;
195 } 195 }
196 return null; 196 return null;
197 } 197 }
198 198
199 protected bool TryGetRegion(ulong regionHandle, out Scene scene) 199 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
200 { 200 {
201 lock (m_scenes) 201 lock (m_scenes)
202 { 202 {
203 foreach (Scene nextScene in m_scenes) 203 foreach (Scene nextScene in m_scenes)
204 { 204 {
205 if (nextScene.RegionInfo.RegionHandle == regionHandle) 205 if (nextScene.RegionInfo.RegionHandle == regionHandle)
206 { 206 {
207 scene = nextScene; 207 scene = nextScene;
208 return true; 208 return true;
209 } 209 }
210 } 210 }
211 } 211 }
212 212
213 scene = null; 213 scene = null;
214 return false; 214 return false;
215 } 215 }
216 216
217 protected bool TryGetRegion(UUID regionID, out Scene scene) 217 protected bool TryGetRegion(UUID regionID, out Scene scene)
218 { 218 {
219 lock (m_scenes) 219 lock (m_scenes)
220 { 220 {
221 foreach (Scene nextScene in m_scenes) 221 foreach (Scene nextScene in m_scenes)
222 { 222 {
223 if (nextScene.RegionInfo.RegionID == regionID) 223 if (nextScene.RegionInfo.RegionID == regionID)
224 { 224 {
225 scene = nextScene; 225 scene = nextScene;
226 return true; 226 return true;
227 } 227 }
228 } 228 }
229 } 229 }
230 230
231 scene = null; 231 scene = null;
232 return false; 232 return false;
233 } 233 }
234 234
235 protected bool TryGetRegion(string regionName, out Scene scene) 235 protected bool TryGetRegion(string regionName, out Scene scene)
236 { 236 {
237 lock (m_scenes) 237 lock (m_scenes)
238 { 238 {
239 foreach (Scene nextScene in m_scenes) 239 foreach (Scene nextScene in m_scenes)
240 { 240 {
241 if (nextScene.RegionInfo.RegionName == regionName) 241 if (nextScene.RegionInfo.RegionName == regionName)
242 { 242 {
243 scene = nextScene; 243 scene = nextScene;
244 return true; 244 return true;
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 scene = null; 249 scene = null;
250 return false; 250 return false;
251 } 251 }
252 } 252 }
253} 253}
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index dedd37f..f9059e0 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -66,18 +66,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
66 /// <param name="data"></param> 66 /// <param name="data"></param>
67 public void ReturnData(UUID id, byte[] data) 67 public void ReturnData(UUID id, byte[] data)
68 { 68 {
69 DynamicTextureUpdater updater = null;
69 70
70 DynamicTextureUpdater updater = null; 71 lock (Updaters)
71
72 lock(Updaters)
73 { 72 {
74 if (Updaters.ContainsKey(id)) 73 if (Updaters.ContainsKey(id))
75 { 74 {
76 updater = Updaters[id]; 75 updater = Updaters[id];
77 } 76 }
78 } 77 }
79 78
80 if(updater != null) 79 if (updater != null)
81 { 80 {
82 if (RegisteredScenes.ContainsKey(updater.SimUUID)) 81 if (RegisteredScenes.ContainsKey(updater.SimUUID))
83 { 82 {
@@ -86,27 +85,26 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
86 } 85 }
87 } 86 }
88 87
89 if(updater.UpdateTimer == 0) 88 if (updater.UpdateTimer == 0)
90 { 89 {
91 lock(Updaters) 90 lock (Updaters)
92 { 91 {
93 if (!Updaters.ContainsKey(updater.UpdaterID)) 92 if (!Updaters.ContainsKey(updater.UpdaterID))
94 { 93 {
95 Updaters.Remove(updater.UpdaterID); 94 Updaters.Remove(updater.UpdaterID);
96 } 95 }
97 } 96 }
98 } 97 }
99
100 } 98 }
101 99
102 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, 100 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
103 string extraParams, int updateTimer) 101 string extraParams, int updateTimer)
104 { 102 {
105 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255); 103 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255);
106 } 104 }
107 105
108 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, 106 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
109 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 107 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
110 { 108 {
111 if (RenderPlugins.ContainsKey(contentType)) 109 if (RenderPlugins.ContainsKey(contentType))
112 { 110 {
@@ -123,12 +121,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
123 updater.BlendWithOldTexture = SetBlending; 121 updater.BlendWithOldTexture = SetBlending;
124 updater.FrontAlpha = AlphaValue; 122 updater.FrontAlpha = AlphaValue;
125 123
126 lock(Updaters) 124 lock (Updaters)
127 { 125 {
128 if (!Updaters.ContainsKey(updater.UpdaterID)) 126 if (!Updaters.ContainsKey(updater.UpdaterID))
129 { 127 {
130 Updaters.Add(updater.UpdaterID, updater); 128 Updaters.Add(updater.UpdaterID, updater);
131 } 129 }
132 } 130 }
133 131
134 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); 132 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
@@ -138,13 +136,13 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
138 } 136 }
139 137
140 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, 138 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
141 string extraParams, int updateTimer) 139 string extraParams, int updateTimer)
142 { 140 {
143 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255); 141 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255);
144 } 142 }
145 143
146 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, 144 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
147 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 145 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
148 { 146 {
149 if (RenderPlugins.ContainsKey(contentType)) 147 if (RenderPlugins.ContainsKey(contentType))
150 { 148 {
@@ -159,12 +157,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
159 updater.BlendWithOldTexture = SetBlending; 157 updater.BlendWithOldTexture = SetBlending;
160 updater.FrontAlpha = AlphaValue; 158 updater.FrontAlpha = AlphaValue;
161 159
162 lock(Updaters) 160 lock (Updaters)
163 { 161 {
164 if (!Updaters.ContainsKey(updater.UpdaterID)) 162 if (!Updaters.ContainsKey(updater.UpdaterID))
165 { 163 {
166 Updaters.Add(updater.UpdaterID, updater); 164 Updaters.Add(updater.UpdaterID, updater);
167 } 165 }
168 } 166 }
169 167
170 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); 168 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
@@ -173,7 +171,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
173 return UUID.Zero; 171 return UUID.Zero;
174 } 172 }
175 173
176
177 public void GetDrawStringSize(string contentType, string text, string fontName, int fontSize, 174 public void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
178 out double xSize, out double ySize) 175 out double xSize, out double ySize)
179 { 176 {
@@ -307,7 +304,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
307 part.ScheduleFullUpdate(); 304 part.ScheduleFullUpdate();
308 305
309 scene.CommsManager.AssetCache.ExpireAsset(oldID); 306 scene.CommsManager.AssetCache.ExpireAsset(oldID);
310
311 } 307 }
312 308
313 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) 309 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3c1b87f..e32f1b4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4998,29 +4998,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4998 4998
4999 if (dir.x == 0) 4999 if (dir.x == 0)
5000 { 5000 {
5001 if (dir.y == 0) 5001 if (dir.y == 0)
5002 { 5002 {
5003 // Direction vector is 0,0 so return 5003 // Direction vector is 0,0 so return
5004 // false since we're staying in the sim 5004 // false since we're staying in the sim
5005 return 0; 5005 return 0;
5006 } 5006 }
5007 else 5007 else
5008 { 5008 {
5009 // Y is the only valid direction 5009 // Y is the only valid direction
5010 edge.y = dir.y / Math.Abs(dir.y); 5010 edge.y = dir.y / Math.Abs(dir.y);
5011 } 5011 }
5012 } 5012 }
5013 else 5013 else
5014 { 5014 {
5015 LSL_Float mag; 5015 LSL_Float mag;
5016 if (dir.x > 0) 5016 if (dir.x > 0)
5017 { 5017 {
5018 mag = (Constants.RegionSize - pos.x) / dir.x; 5018 mag = (Constants.RegionSize - pos.x) / dir.x;
5019 } 5019 }
5020 else 5020 else
5021 { 5021 {
5022 mag = (pos.x/dir.x); 5022 mag = (pos.x/dir.x);
5023 } 5023 }
5024 5024
5025 mag = Math.Abs(mag); 5025 mag = Math.Abs(mag);
5026 5026
@@ -5028,7 +5028,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5028 5028
5029 if (edge.y > Constants.RegionSize || edge.y < 0) 5029 if (edge.y > Constants.RegionSize || edge.y < 0)
5030 { 5030 {
5031 // Y goes out of bounds first 5031 // Y goes out of bounds first
5032 edge.y = dir.y / Math.Abs(dir.y); 5032 edge.y = dir.y / Math.Abs(dir.y);
5033 } 5033 }
5034 else 5034 else
@@ -5039,18 +5039,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5039 } 5039 }
5040 } 5040 }
5041 5041
5042 List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY); 5042 List<SimpleRegionInfo> neighbors = World.CommsManager.GridService.RequestNeighbours(World.RegionInfo.RegionLocX, World.RegionInfo.RegionLocY);
5043 5043
5044 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x; 5044 uint neighborX = World.RegionInfo.RegionLocX + (uint)dir.x;
5045 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y; 5045 uint neighborY = World.RegionInfo.RegionLocY + (uint)dir.y;
5046 5046
5047 foreach (SimpleRegionInfo sri in neighbors) 5047 foreach (SimpleRegionInfo sri in neighbors)
5048 { 5048 {
5049 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY) 5049 if (sri.RegionLocX == neighborX && sri.RegionLocY == neighborY)
5050 return 0; 5050 return 0;
5051 } 5051 }
5052 5052
5053 return 1; 5053 return 1;
5054 } 5054 }
5055 5055
5056 /// <summary> 5056 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index 09351fd..5353fc9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -49,7 +49,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
49 { 49 {
50 return localID.ToString() + itemID.ToString(); 50 return localID.ToString() + itemID.ToString();
51 } 51 }
52
53 52
54 private class TimerClass 53 private class TimerClass
55 { 54 {