aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs5
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs9
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs90
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs11
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs19
-rw-r--r--OpenSim/Services/Base/ServiceBase.cs2
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs366
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs7
-rw-r--r--OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs68
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServicesConnector.cs10
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs1
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs66
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs11
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs3
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs13
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs5
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs31
-rw-r--r--OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs5
-rw-r--r--OpenSim/Services/GridService/GridService.cs29
-rw-r--r--OpenSim/Services/GridService/HypergridLinker.cs6
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs2
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs5
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IAttachmentsService.cs38
-rw-r--r--OpenSim/Services/Interfaces/IAuthenticationService.cs1
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs11
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs35
-rw-r--r--OpenSim/Services/Interfaces/ILoginService.cs4
-rw-r--r--OpenSim/Services/Interfaces/IMapImageService.cs6
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs19
-rw-r--r--OpenSim/Services/Interfaces/IUserAccountService.cs5
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs22
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs32
-rw-r--r--OpenSim/Services/MapImageService/MapImageService.cs119
-rw-r--r--OpenSim/Services/SimulationService/SimulationDataService.cs5
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs21
-rw-r--r--OpenSim/Services/UserProfilesService/UserProfilesService.cs2
42 files changed, 840 insertions, 271 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 0aefa16..c57db48 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -174,7 +174,10 @@ namespace OpenSim.Services.AssetService
174 { 174 {
175// m_log.DebugFormat( 175// m_log.DebugFormat(
176// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); 176// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
177 m_Database.StoreAsset(asset); 177 if (!m_Database.StoreAsset(asset))
178 {
179 return UUID.Zero.ToString();
180 }
178 } 181 }
179// else 182// else
180// { 183// {
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 229f557..e42f9a0 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -30,10 +30,11 @@ using OpenMetaverse;
30using log4net; 30using log4net;
31using Nini.Config; 31using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
33using OpenSim.Data; 35using OpenSim.Data;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Services.Base; 37using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces;
37 38
38namespace OpenSim.Services.AuthenticationService 39namespace OpenSim.Services.AuthenticationService
39{ 40{
@@ -50,6 +51,12 @@ namespace OpenSim.Services.AuthenticationService
50 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 protected IAuthenticationData m_Database; 53 protected IAuthenticationData m_Database;
54 protected IUserAccountService m_UserAccountService = null;
55
56 public AuthenticationServiceBase(IConfigSource config, IUserAccountService acct) : this(config)
57 {
58 m_UserAccountService = acct;
59 }
53 60
54 public AuthenticationServiceBase(IConfigSource config) : base(config) 61 public AuthenticationServiceBase(IConfigSource config) : base(config)
55 { 62 {
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 5f1bde1..a069838 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -51,6 +51,12 @@ namespace OpenSim.Services.AuthenticationService
51 LogManager.GetLogger( 51 LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType); 52 MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config, IUserAccountService userService) :
55 base(config, userService)
56 {
57 m_log.Debug("[AUTH SERVICE]: Started with User Account access");
58 }
59
54 public PasswordAuthenticationService(IConfigSource config) : 60 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 61 base(config)
56 { 62 {
@@ -58,42 +64,90 @@ namespace OpenSim.Services.AuthenticationService
58 64
59 public string Authenticate(UUID principalID, string password, int lifetime) 65 public string Authenticate(UUID principalID, string password, int lifetime)
60 { 66 {
67 UUID realID;
68 return Authenticate(principalID, password, lifetime, out realID);
69 }
70
71 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
72 {
73 realID = UUID.Zero;
74
75 m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null);
61 AuthenticationData data = m_Database.Get(principalID); 76 AuthenticationData data = m_Database.Get(principalID);
77 UserAccount user = null;
78 if (m_UserAccountService != null)
79 user = m_UserAccountService.GetUserAccount(UUID.Zero, principalID);
62 80
63 if (data == null) 81 if (data == null || data.Data == null)
64 { 82 {
65 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} not found", principalID); 83 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
66 return String.Empty; 84 return String.Empty;
67 } 85 }
68 else if (data.Data == null) 86
87 if (!data.Data.ContainsKey("passwordHash") ||
88 !data.Data.ContainsKey("passwordSalt"))
69 { 89 {
70 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} data not found", principalID);
71 return String.Empty; 90 return String.Empty;
72 } 91 }
73 else if (!data.Data.ContainsKey("passwordHash") || !data.Data.ContainsKey("passwordSalt")) 92
93 string hashed = Util.Md5Hash(password + ":" +
94 data.Data["passwordSalt"].ToString());
95
96 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
97
98 if (data.Data["passwordHash"].ToString() == hashed)
99 {
100 return GetToken(principalID, lifetime);
101 }
102
103 if (user == null)
74 { 104 {
75 m_log.DebugFormat( 105 m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID);
76 "[AUTH SERVICE]: PrincipalID {0} data didn't contain either passwordHash or passwordSalt", principalID);
77 return String.Empty; 106 return String.Empty;
78 } 107 }
79 else 108
109 int impersonateFlag = 1 << 6;
110
111 if ((user.UserFlags & impersonateFlag) == 0)
112 return String.Empty;
113
114 m_log.DebugFormat("[PASS AUTH]: Attempting impersonation");
115
116 List<UserAccount> accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200");
117 if (accounts == null || accounts.Count == 0)
118 return String.Empty;
119
120 foreach (UserAccount a in accounts)
80 { 121 {
81 string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); 122 data = m_Database.Get(a.PrincipalID);
123 if (data == null || data.Data == null ||
124 !data.Data.ContainsKey("passwordHash") ||
125 !data.Data.ContainsKey("passwordSalt"))
126 {
127 continue;
128 }
129
130// m_log.DebugFormat("[PASS AUTH]: Trying {0}", data.PrincipalID);
82 131
83 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); 132 hashed = Util.Md5Hash(password + ":" +
133 data.Data["passwordSalt"].ToString());
84 134
85 if (data.Data["passwordHash"].ToString() == hashed) 135 if (data.Data["passwordHash"].ToString() == hashed)
86 { 136 {
137 m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID);
138 realID = a.PrincipalID;
87 return GetToken(principalID, lifetime); 139 return GetToken(principalID, lifetime);
88 } 140 }
89 else 141// else
90 { 142// {
91 m_log.DebugFormat( 143// m_log.DebugFormat(
92 "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", 144// "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.",
93 hashed, data.Data["passwordHash"], principalID); 145// hashed, data.Data["passwordHash"], data.PrincipalID);
94 return String.Empty; 146// }
95 }
96 } 147 }
148
149 m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID);
150 return String.Empty;
97 } 151 }
98 } 152 }
99} \ No newline at end of file 153}
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 2344c0e..1510168 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -49,12 +49,23 @@ namespace OpenSim.Services.AuthenticationService
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger( 50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType); 51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 public WebkeyAuthenticationService(IConfigSource config, IUserAccountService userService) :
54 base(config, userService)
55 {
56 }
52 57
53 public WebkeyAuthenticationService(IConfigSource config) : 58 public WebkeyAuthenticationService(IConfigSource config) :
54 base(config) 59 base(config)
55 { 60 {
56 } 61 }
57 62
63 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
64 {
65 realID = UUID.Zero;
66 return Authenticate(principalID, password, lifetime);
67 }
68
58 public string Authenticate(UUID principalID, string password, int lifetime) 69 public string Authenticate(UUID principalID, string password, int lifetime)
59 { 70 {
60 if (new UUID(password) == UUID.Zero) 71 if (new UUID(password) == UUID.Zero)
diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
index 2c6cebd..bbc8470 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
@@ -55,14 +55,22 @@ namespace OpenSim.Services.AuthenticationService
55 55
56 public string Authenticate(UUID principalID, string password, int lifetime) 56 public string Authenticate(UUID principalID, string password, int lifetime)
57 { 57 {
58 UUID realID;
59
60 return Authenticate(principalID, password, lifetime, out realID);
61 }
62
63 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
64 {
58 AuthenticationData data = m_Database.Get(principalID); 65 AuthenticationData data = m_Database.Get(principalID);
59 string result = String.Empty; 66 string result = String.Empty;
67 realID = UUID.Zero;
60 if (data != null && data.Data != null) 68 if (data != null && data.Data != null)
61 { 69 {
62 if (data.Data.ContainsKey("webLoginKey")) 70 if (data.Data.ContainsKey("webLoginKey"))
63 { 71 {
64 m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); 72 m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID);
65 result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime); 73 result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime, out realID);
66 if (result == String.Empty) 74 if (result == String.Empty)
67 { 75 {
68 m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); 76 m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID);
@@ -71,12 +79,15 @@ namespace OpenSim.Services.AuthenticationService
71 if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) 79 if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt"))
72 { 80 {
73 m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); 81 m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID);
74 result = m_svcChecks["password"].Authenticate(principalID, password, lifetime); 82 result = m_svcChecks["password"].Authenticate(principalID, password, lifetime, out realID);
75 if (result == String.Empty) 83 if (result == String.Empty)
76 { 84 {
77 m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); 85 m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID);
78 } 86 }
79 } 87 }
88
89
90
80 if (result == string.Empty) 91 if (result == string.Empty)
81 { 92 {
82 m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID); 93 m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID);
@@ -86,7 +97,9 @@ namespace OpenSim.Services.AuthenticationService
86 { 97 {
87 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID); 98 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
88 } 99 }
100
101
89 return result; 102 return result;
90 } 103 }
91 } 104 }
92} \ No newline at end of file 105}
diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs
index a7eb2be..c18226b 100644
--- a/OpenSim/Services/Base/ServiceBase.cs
+++ b/OpenSim/Services/Base/ServiceBase.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using System.Reflection; 32using System.Reflection;
@@ -54,6 +55,7 @@ namespace OpenSim.Services.Base
54 string noRoot = dllName.Substring(pathRoot.Length); 55 string noRoot = dllName.Substring(pathRoot.Length);
55 string[] parts = noRoot.Split(new char[] {':'}); 56 string[] parts = noRoot.Split(new char[] {':'});
56 57
58
57 dllName = pathRoot + parts[0]; 59 dllName = pathRoot + parts[0];
58 60
59 string className = String.Empty; 61 string className = String.Empty;
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index bd43552..622780a 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -27,9 +27,11 @@
27 27
28using log4net; 28using log4net;
29using System; 29using System;
30using System.Threading;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.IO; 32using System.IO;
32using System.Reflection; 33using System.Reflection;
34using System.Timers;
33using Nini.Config; 35using Nini.Config;
34using OpenSim.Framework; 36using OpenSim.Framework;
35using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
@@ -46,13 +48,22 @@ namespace OpenSim.Services.Connectors
46 48
47 private string m_ServerURI = String.Empty; 49 private string m_ServerURI = String.Empty;
48 private IImprovedAssetCache m_Cache = null; 50 private IImprovedAssetCache m_Cache = null;
51 private int m_retryCounter;
52 private Dictionary<int, List<AssetBase>> m_retryQueue = new Dictionary<int, List<AssetBase>>();
53 private System.Timers.Timer m_retryTimer;
49 private int m_maxAssetRequestConcurrency = 30; 54 private int m_maxAssetRequestConcurrency = 30;
50 55
51 private delegate void AssetRetrievedEx(AssetBase asset); 56 private delegate void AssetRetrievedEx(AssetBase asset);
52 57
53 // Keeps track of concurrent requests for the same asset, so that it's only loaded once. 58 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
54 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 59 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
55 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 60// private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
61
62 private Dictionary<string, List<AssetRetrievedEx>> m_AssetHandlers = new Dictionary<string, List<AssetRetrievedEx>>();
63
64 private Dictionary<string, string> m_UriMap = new Dictionary<string, string>();
65
66 private Thread[] m_fetchThreads;
56 67
57 public int MaxAssetRequestConcurrency 68 public int MaxAssetRequestConcurrency
58 { 69 {
@@ -91,13 +102,113 @@ namespace OpenSim.Services.Connectors
91 string serviceURI = assetConfig.GetString("AssetServerURI", 102 string serviceURI = assetConfig.GetString("AssetServerURI",
92 String.Empty); 103 String.Empty);
93 104
105 m_ServerURI = serviceURI;
106
94 if (serviceURI == String.Empty) 107 if (serviceURI == String.Empty)
95 { 108 {
96 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); 109 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
97 throw new Exception("Asset connector init error"); 110 throw new Exception("Asset connector init error");
98 } 111 }
99 112
100 m_ServerURI = serviceURI; 113
114 m_retryTimer = new System.Timers.Timer();
115 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
116 m_retryTimer.Interval = 60000;
117
118 Uri serverUri = new Uri(m_ServerURI);
119
120 string groupHost = serverUri.Host;
121
122 for (int i = 0 ; i < 256 ; i++)
123 {
124 string prefix = i.ToString("x2");
125 groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost);
126
127 m_UriMap[prefix] = groupHost;
128 //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix);
129 }
130
131 m_fetchThreads = new Thread[2];
132
133 for (int i = 0 ; i < 2 ; i++)
134 {
135 m_fetchThreads[i] = new Thread(AssetRequestProcessor);
136 m_fetchThreads[i].Start();
137 }
138 }
139
140 private string MapServer(string id)
141 {
142 if (m_UriMap.Count == 0)
143 return m_ServerURI;
144
145 UriBuilder serverUri = new UriBuilder(m_ServerURI);
146
147 string prefix = id.Substring(0, 2).ToLower();
148
149 string host;
150
151 // HG URLs will not be valid UUIDS
152 if (m_UriMap.ContainsKey(prefix))
153 host = m_UriMap[prefix];
154 else
155 host = m_UriMap["00"];
156
157 serverUri.Host = host;
158
159 // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix);
160
161 string ret = serverUri.Uri.AbsoluteUri;
162 if (ret.EndsWith("/"))
163 ret = ret.Substring(0, ret.Length - 1);
164 return ret;
165 }
166
167 protected void retryCheck(object source, ElapsedEventArgs e)
168 {
169 m_retryCounter++;
170 if (m_retryCounter > 60)
171 m_retryCounter -= 60;
172
173 List<int> keys = new List<int>();
174 foreach (int a in m_retryQueue.Keys)
175 {
176 keys.Add(a);
177 }
178 foreach (int a in keys)
179 {
180 //We exponentially fall back on frequency until we reach one attempt per hour
181 //The net result is that we end up in the queue for roughly 24 hours..
182 //24 hours worth of assets could be a lot, so the hope is that the region admin
183 //will have gotten the asset connector back online quickly!
184
185 int timefactor = a ^ 2;
186 if (timefactor > 60)
187 {
188 timefactor = 60;
189 }
190
191 //First, find out if we care about this timefactor
192 if (timefactor % a == 0)
193 {
194 //Yes, we do!
195 List<AssetBase> retrylist = m_retryQueue[a];
196 m_retryQueue.Remove(a);
197
198 foreach(AssetBase ass in retrylist)
199 {
200 Store(ass); //Store my ass. This function will put it back in the dictionary if it fails
201 }
202 }
203 }
204
205 if (m_retryQueue.Count == 0)
206 {
207 //It might only be one tick per minute, but I have
208 //repented and abandoned my wasteful ways
209 m_retryCounter = 0;
210 m_retryTimer.Stop();
211 }
101 } 212 }
102 213
103 protected void SetCache(IImprovedAssetCache cache) 214 protected void SetCache(IImprovedAssetCache cache)
@@ -107,15 +218,13 @@ namespace OpenSim.Services.Connectors
107 218
108 public AssetBase Get(string id) 219 public AssetBase Get(string id)
109 { 220 {
110// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Synchronous get request for {0}", id); 221 string uri = MapServer(id) + "/assets/" + id;
111
112 string uri = m_ServerURI + "/assets/" + id;
113 222
114 AssetBase asset = null; 223 AssetBase asset = null;
115 if (m_Cache != null) 224 if (m_Cache != null)
116 asset = m_Cache.Get(id); 225 asset = m_Cache.Get(id);
117 226
118 if (asset == null) 227 if (asset == null || asset.Data == null || asset.Data.Length == 0)
119 { 228 {
120 // XXX: Commented out for now since this has either never been properly operational or not for some time 229 // XXX: Commented out for now since this has either never been properly operational or not for some time
121 // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option. 230 // as m_maxAssetRequestConcurrency was being passed as the timeout, not a concurrency limiting option.
@@ -154,7 +263,7 @@ namespace OpenSim.Services.Connectors
154 return fullAsset.Metadata; 263 return fullAsset.Metadata;
155 } 264 }
156 265
157 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 266 string uri = MapServer(id) + "/assets/" + id + "/metadata";
158 267
159 AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth); 268 AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
160 return asset; 269 return asset;
@@ -170,7 +279,7 @@ namespace OpenSim.Services.Connectors
170 return fullAsset.Data; 279 return fullAsset.Data;
171 } 280 }
172 281
173 using (RestClient rc = new RestClient(m_ServerURI)) 282 using (RestClient rc = new RestClient(MapServer(id)))
174 { 283 {
175 rc.AddResourcePath("assets"); 284 rc.AddResourcePath("assets");
176 rc.AddResourcePath(id); 285 rc.AddResourcePath(id);
@@ -178,83 +287,136 @@ namespace OpenSim.Services.Connectors
178 287
179 rc.RequestMethod = "GET"; 288 rc.RequestMethod = "GET";
180 289
181 Stream s = rc.Request(m_Auth); 290 using (Stream s = rc.Request(m_Auth))
182
183 if (s == null)
184 return null;
185
186 if (s.Length > 0)
187 { 291 {
188 byte[] ret = new byte[s.Length]; 292 if (s == null)
189 s.Read(ret, 0, (int)s.Length); 293 return null;
190 294
191 return ret; 295 if (s.Length > 0)
192 } 296 {
297 byte[] ret = new byte[s.Length];
298 s.Read(ret, 0, (int)s.Length);
193 299
300 return ret;
301 }
302 }
194 return null; 303 return null;
195 } 304 }
196 } 305 }
197 306
198 public bool Get(string id, Object sender, AssetRetrieved handler) 307 private class QueuedAssetRequest
199 { 308 {
200// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Potentially asynchronous get request for {0}", id); 309 public string uri;
310 public string id;
311 }
201 312
202 string uri = m_ServerURI + "/assets/" + id; 313 private OpenMetaverse.BlockingQueue<QueuedAssetRequest> m_requestQueue =
314 new OpenMetaverse.BlockingQueue<QueuedAssetRequest>();
203 315
204 AssetBase asset = null; 316 private void AssetRequestProcessor()
205 if (m_Cache != null) 317 {
206 asset = m_Cache.Get(id); 318 QueuedAssetRequest r;
207 319
208 if (asset == null) 320 while (true)
209 { 321 {
210 lock (m_AssetHandlers) 322 r = m_requestQueue.Dequeue();
211 {
212 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
213 323
214 AssetRetrievedEx handlers; 324 string uri = r.uri;
215 if (m_AssetHandlers.TryGetValue(id, out handlers)) 325 string id = r.id;
216 {
217 // Someone else is already loading this asset. It will notify our handler when done.
218 handlers += handlerEx;
219 return true;
220 }
221
222 // Load the asset ourselves
223 handlers += handlerEx;
224 m_AssetHandlers.Add(id, handlers);
225 }
226 326
227 bool success = false; 327 bool success = false;
228 try 328 try
229 { 329 {
230 AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 330 AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 30000, m_Auth);
231 delegate(AssetBase a) 331 if (a != null)
332 {
333 if (m_Cache != null)
334 m_Cache.Cache(a);
335
336 List<AssetRetrievedEx> handlers;
337 lock (m_AssetHandlers)
232 { 338 {
233 if (a != null && m_Cache != null) 339 handlers = m_AssetHandlers[id];
234 m_Cache.Cache(a); 340 m_AssetHandlers.Remove(id);
341 }
235 342
236 AssetRetrievedEx handlers; 343 Util.FireAndForget(x =>
237 lock (m_AssetHandlers)
238 { 344 {
239 handlers = m_AssetHandlers[id]; 345
240 m_AssetHandlers.Remove(id); 346 foreach (AssetRetrievedEx h in handlers)
241 } 347 {
242 handlers.Invoke(a); 348 // Util.FireAndForget(x =>
243 }, m_maxAssetRequestConcurrency, m_Auth); 349 // {
244 350 try { h.Invoke(a); }
245 success = true; 351 catch { }
352 // });
353 }
354
355 if (handlers != null)
356 handlers.Clear();
357
358 });
359
360// if (handlers != null)
361// handlers.Clear();
362 success = true;
363 }
246 } 364 }
247 finally 365 finally
248 { 366 {
249 if (!success) 367 if (!success)
250 { 368 {
369 List<AssetRetrievedEx> handlers;
251 lock (m_AssetHandlers) 370 lock (m_AssetHandlers)
252 { 371 {
372 handlers = m_AssetHandlers[id];
253 m_AssetHandlers.Remove(id); 373 m_AssetHandlers.Remove(id);
254 } 374 }
375 if (handlers != null)
376 handlers.Clear();
255 } 377 }
256 } 378 }
257 } 379 }
380 }
381
382 public bool Get(string id, Object sender, AssetRetrieved handler)
383 {
384 string uri = MapServer(id) + "/assets/" + id;
385
386 AssetBase asset = null;
387 if (m_Cache != null)
388 asset = m_Cache.Get(id);
389
390 if (asset == null || asset.Data == null || asset.Data.Length == 0)
391 {
392 lock (m_AssetHandlers)
393 {
394 AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); });
395
396// AssetRetrievedEx handlers;
397 List<AssetRetrievedEx> handlers;
398 if (m_AssetHandlers.TryGetValue(id, out handlers))
399 {
400 // Someone else is already loading this asset. It will notify our handler when done.
401// handlers += handlerEx;
402 handlers.Add(handlerEx);
403 return true;
404 }
405
406 // Load the asset ourselves
407// handlers += handlerEx;
408 handlers = new List<AssetRetrievedEx>();
409 handlers.Add(handlerEx);
410
411 m_AssetHandlers.Add(id, handlers);
412 }
413
414 QueuedAssetRequest request = new QueuedAssetRequest();
415 request.id = id;
416 request.uri = uri;
417
418 m_requestQueue.Enqueue(request);
419 }
258 else 420 else
259 { 421 {
260 handler(id, sender, asset); 422 handler(id, sender, asset);
@@ -286,43 +448,95 @@ namespace OpenSim.Services.Connectors
286 448
287 public string Store(AssetBase asset) 449 public string Store(AssetBase asset)
288 { 450 {
289 if (asset.Local) 451 // Have to assign the asset ID here. This isn't likely to
452 // trigger since current callers don't pass emtpy IDs
453 // We need the asset ID to route the request to the proper
454 // cluster member, so we can't have the server assign one.
455 if (asset.ID == string.Empty)
290 { 456 {
291 if (m_Cache != null) 457 if (asset.FullID == UUID.Zero)
292 m_Cache.Cache(asset); 458 {
459 asset.FullID = UUID.Random();
460 }
461 asset.ID = asset.FullID.ToString();
462 }
463 else if (asset.FullID == UUID.Zero)
464 {
465 UUID uuid = UUID.Zero;
466 if (UUID.TryParse(asset.ID, out uuid))
467 {
468 asset.FullID = uuid;
469 }
470 else
471 {
472 asset.FullID = UUID.Random();
473 }
474 }
293 475
476 if (m_Cache != null)
477 m_Cache.Cache(asset);
478 if (asset.Temporary || asset.Local)
479 {
294 return asset.ID; 480 return asset.ID;
295 } 481 }
296 482
297 string uri = m_ServerURI + "/assets/"; 483 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
298 484
299 string newID; 485 string newID;
300 try 486 try
301 { 487 {
302 newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, m_Auth); 488 newID = SynchronousRestObjectRequester.
489 MakeRequest<AssetBase, string>("POST", uri, asset, 100000, m_Auth);
490 if (newID == null || newID == "")
491 {
492 newID = UUID.Zero.ToString();
493 }
303 } 494 }
304 catch (Exception e) 495 catch (Exception e)
305 { 496 {
306 m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e); 497 newID = UUID.Zero.ToString();
307 return string.Empty;
308 } 498 }
309 499
310 // TEMPORARY: SRAS returns 'null' when it's asked to store existing assets 500 if (newID == UUID.Zero.ToString())
311 if (newID == null)
312 { 501 {
313 m_log.DebugFormat("[ASSET CONNECTOR]: Storing of asset {0} returned null; assuming the asset already exists", asset.ID); 502 //The asset upload failed, put it in a queue for later
314 return asset.ID; 503 asset.UploadAttempts++;
504 if (asset.UploadAttempts > 30)
505 {
506 //By this stage we've been in the queue for a good few hours;
507 //We're going to drop the asset.
508 m_log.ErrorFormat("[Assets] Dropping asset {0} - Upload has been in the queue for too long.", asset.ID.ToString());
509 }
510 else
511 {
512 if (!m_retryQueue.ContainsKey(asset.UploadAttempts))
513 {
514 m_retryQueue.Add(asset.UploadAttempts, new List<AssetBase>());
515 }
516 List<AssetBase> m_queue = m_retryQueue[asset.UploadAttempts];
517 m_queue.Add(asset);
518 m_log.WarnFormat("[Assets] Upload failed: {0} - Requeuing asset for another run.", asset.ID.ToString());
519 m_retryTimer.Start();
520 }
315 } 521 }
522 else
523 {
524 if (asset.UploadAttempts > 0)
525 {
526 m_log.InfoFormat("[Assets] Upload of {0} succeeded after {1} failed attempts", asset.ID.ToString(), asset.UploadAttempts.ToString());
527 }
528 if (newID != String.Empty)
529 {
530 // Placing this here, so that this work with old asset servers that don't send any reply back
531 // SynchronousRestObjectRequester returns somethins that is not an empty string
532 if (newID != null)
533 asset.ID = newID;
316 534
317 if (string.IsNullOrEmpty(newID)) 535 if (m_Cache != null)
318 return string.Empty; 536 m_Cache.Cache(asset);
319 537 }
320 asset.ID = newID; 538 }
321 539 return asset.ID;
322 if (m_Cache != null)
323 m_Cache.Cache(asset);
324
325 return newID;
326 } 540 }
327 541
328 public bool UpdateContent(string id, byte[] data) 542 public bool UpdateContent(string id, byte[] data)
@@ -343,7 +557,7 @@ namespace OpenSim.Services.Connectors
343 } 557 }
344 asset.Data = data; 558 asset.Data = data;
345 559
346 string uri = m_ServerURI + "/assets/" + id; 560 string uri = MapServer(id) + "/assets/" + id;
347 561
348 if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth)) 562 if (SynchronousRestObjectRequester.MakeRequest<AssetBase, bool>("POST", uri, asset, m_Auth))
349 { 563 {
@@ -357,7 +571,7 @@ namespace OpenSim.Services.Connectors
357 571
358 public bool Delete(string id) 572 public bool Delete(string id)
359 { 573 {
360 string uri = m_ServerURI + "/assets/" + id; 574 string uri = MapServer(id) + "/assets/" + id;
361 575
362 if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth)) 576 if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth))
363 { 577 {
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
index c8a4912..0443f5a 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs
@@ -84,6 +84,13 @@ namespace OpenSim.Services.Connectors
84 base.Initialise(source, "AuthenticationService"); 84 base.Initialise(source, "AuthenticationService");
85 } 85 }
86 86
87 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
88 {
89 realID = UUID.Zero;
90
91 return Authenticate(principalID, password, lifetime);
92 }
93
87 public string Authenticate(UUID principalID, string password, int lifetime) 94 public string Authenticate(UUID principalID, string password, int lifetime)
88 { 95 {
89 Dictionary<string, object> sendData = new Dictionary<string, object>(); 96 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
index 6d5ce4b..45f4514 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
@@ -144,44 +144,48 @@ namespace OpenSim.Services.Connectors.Friends
144 144
145 private bool Call(GridRegion region, Dictionary<string, object> sendData) 145 private bool Call(GridRegion region, Dictionary<string, object> sendData)
146 { 146 {
147 string reqString = ServerUtils.BuildQueryString(sendData); 147 Util.FireAndForget(x => {
148 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString); 148 string reqString = ServerUtils.BuildQueryString(sendData);
149 if (region == null) 149 //m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: queryString = {0}", reqString);
150 return false; 150 if (region == null)
151 151 return;
152 string path = ServicePath(); 152
153 if (!region.ServerURI.EndsWith("/")) 153 string path = ServicePath();
154 path = "/" + path; 154 if (!region.ServerURI.EndsWith("/"))
155 string uri = region.ServerURI + path; 155 path = "/" + path;
156// m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); 156 string uri = region.ServerURI + path;
157 157 // m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri);
158 try 158
159 { 159 try
160 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
161 if (reply != string.Empty)
162 { 160 {
163 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 161 string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString);
164 162 if (reply != string.Empty)
165 if (replyData.ContainsKey("RESULT"))
166 { 163 {
167 if (replyData["RESULT"].ToString().ToLower() == "true") 164 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
168 return true; 165
166 if (replyData.ContainsKey("RESULT"))
167 {
168// if (replyData["RESULT"].ToString().ToLower() == "true")
169// return;
170// else
171 return;
172 }
169 else 173 else
170 return false; 174 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field");
175
171 } 176 }
172 else 177 else
173 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: reply data does not contain result field"); 178 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply");
174 179 }
180 catch (Exception e)
181 {
182 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
175 } 183 }
176 else 184
177 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: received empty reply"); 185 return;
178 } 186 });
179 catch (Exception e) 187
180 { 188 return true;
181 m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: Exception when contacting remote sim at {0}: {1}", uri, e.Message);
182 }
183
184 return false;
185 } 189 }
186 } 190 }
187} 191}
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
index 596f867..6c6ccf9 100644
--- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs
@@ -49,6 +49,9 @@ namespace OpenSim.Services.Connectors
49 49
50 private string m_ServerURI = String.Empty; 50 private string m_ServerURI = String.Empty;
51 51
52 private ExpiringCache<ulong, GridRegion> m_regionCache =
53 new ExpiringCache<ulong, GridRegion>();
54
52 public GridServicesConnector() 55 public GridServicesConnector()
53 { 56 {
54 } 57 }
@@ -275,6 +278,11 @@ namespace OpenSim.Services.Connectors
275 278
276 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 279 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
277 { 280 {
281 ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);
282
283 if (m_regionCache.Contains(regionHandle))
284 return (GridRegion)m_regionCache[regionHandle];
285
278 Dictionary<string, object> sendData = new Dictionary<string, object>(); 286 Dictionary<string, object> sendData = new Dictionary<string, object>();
279 287
280 sendData["SCOPEID"] = scopeID.ToString(); 288 sendData["SCOPEID"] = scopeID.ToString();
@@ -316,6 +324,8 @@ namespace OpenSim.Services.Connectors
316 else 324 else
317 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply"); 325 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
318 326
327 m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));
328
319 return rinfo; 329 return rinfo;
320 } 330 }
321 331
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index b1663ee..2340998 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -161,6 +161,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
161 try 161 try
162 { 162 {
163 WebClient c = new WebClient(); 163 WebClient c = new WebClient();
164 //m_log.Debug("JPEG: " + imageURL);
164 string name = regionID.ToString(); 165 string name = regionID.ToString();
165 filename = Path.Combine(storagePath, name + ".jpg"); 166 filename = Path.Combine(storagePath, name + ".jpg");
166 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); 167 m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename);
@@ -189,11 +190,10 @@ namespace OpenSim.Services.Connectors.Hypergrid
189 190
190 ass.Data = imageData; 191 ass.Data = imageData;
191 192
192 mapTile = ass.FullID;
193
194 // finally
195 m_AssetService.Store(ass); 193 m_AssetService.Store(ass);
196 194
195 // finally
196 mapTile = ass.FullID;
197 } 197 }
198 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke 198 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
199 { 199 {
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 8abd046..1dcc82a 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -138,7 +138,8 @@ namespace OpenSim.Services.Connectors.Hypergrid
138 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI); 138 Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI);
139 139
140 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome; 140 uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome;
141 return CreateAgent(source, home, aCircuit, flags, out reason); 141 EntityTransferContext ctx = new EntityTransferContext();
142 return CreateAgent(source, home, aCircuit, flags, ctx, out reason);
142 } 143 }
143 144
144 145
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
index 7cecd93..c7d658a 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs
@@ -559,6 +559,7 @@ namespace OpenSim.Services.Connectors
559 List<UUID> pending = new List<UUID>(); 559 List<UUID> pending = new List<UUID>();
560 InventoryItemBase item = null; 560 InventoryItemBase item = null;
561 int i = 0; 561 int i = 0;
562
562 foreach (UUID id in itemIDs) 563 foreach (UUID id in itemIDs)
563 { 564 {
564 if (m_ItemCache.TryGetValue(id, out item)) 565 if (m_ItemCache.TryGetValue(id, out item))
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
index 034c42e..7839a68 100644
--- a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -130,4 +130,4 @@ namespace OpenSim.Services.Connectors
130 return landData; 130 return landData;
131 } 131 }
132 } 132 }
133} \ No newline at end of file 133}
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
index c91ed84..84c4efe 100644
--- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
+++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs
@@ -149,13 +149,75 @@ namespace OpenSim.Services.Connectors
149 return false; 149 return false;
150 } 150 }
151 151
152 public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) 152 public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason)
153 { 153 {
154 reason = string.Empty; 154 reason = string.Empty;
155 int tickstart = Util.EnvironmentTickCount(); 155 int tickstart = Util.EnvironmentTickCount();
156 Dictionary<string, object> sendData = new Dictionary<string, object>(); 156 Dictionary<string, object> sendData = new Dictionary<string, object>();
157 sendData["X"] = x.ToString(); 157 sendData["X"] = x.ToString();
158 sendData["Y"] = y.ToString(); 158 sendData["Y"] = y.ToString();
159 sendData["SCOPE"] = scopeID.ToString();
160
161 string reqString = ServerUtils.BuildQueryString(sendData);
162 string uri = m_ServerURI + "/removemap";
163
164 try
165 {
166 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
167 uri,
168 reqString);
169 if (reply != string.Empty)
170 {
171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
172
173 if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success"))
174 {
175 return true;
176 }
177 else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure"))
178 {
179 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Delete failed: {0}", replyData["Message"].ToString());
180 reason = replyData["Message"].ToString();
181 return false;
182 }
183 else if (!replyData.ContainsKey("Result"))
184 {
185 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field");
186 }
187 else
188 {
189 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
190 reason = "Unexpected result " + replyData["Result"].ToString();
191 }
192
193 }
194 else
195 {
196 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Map post received null reply");
197 }
198 }
199 catch (Exception e)
200 {
201 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting map server at {0}: {1}", uri, e.Message);
202 }
203 finally
204 {
205 // This just dumps a warning for any operation that takes more than 100 ms
206 int tickdiff = Util.EnvironmentTickCountSubtract(tickstart);
207 m_log.DebugFormat("[MAP IMAGE CONNECTOR]: map tile deleted in {0}ms", tickdiff);
208 }
209
210 return false;
211 }
212
213 public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string reason)
214 {
215 reason = string.Empty;
216 int tickstart = Util.EnvironmentTickCount();
217 Dictionary<string, object> sendData = new Dictionary<string, object>();
218 sendData["X"] = x.ToString();
219 sendData["Y"] = y.ToString();
220 sendData["SCOPE"] = scopeID.ToString();
159 sendData["TYPE"] = "image/jpeg"; 221 sendData["TYPE"] = "image/jpeg";
160 sendData["DATA"] = Convert.ToBase64String(jpgData); 222 sendData["DATA"] = Convert.ToBase64String(jpgData);
161 223
@@ -216,7 +278,7 @@ namespace OpenSim.Services.Connectors
216 278
217 } 279 }
218 280
219 public byte[] GetMapTile(string fileName, out string format) 281 public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
220 { 282 {
221 format = string.Empty; 283 format = string.Empty;
222 new Exception("GetMapTile method not Implemented"); 284 new Exception("GetMapTile method not Implemented");
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 925364a..939059d 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -153,9 +153,9 @@ namespace OpenSim.Services.Connectors
153 } 153 }
154 catch (Exception e) 154 catch (Exception e)
155 { 155 {
156 m_log.Warn(string.Format( 156// m_log.WarnFormat(
157 "[NEIGHBOUR SERVICES CONNECTOR]: Unable to send HelloNeighbour from {0} to {1} (uri {2}). Exception {3} ", 157// "[NEIGHBOUR SERVICE CONNCTOR]: Unable to send HelloNeighbour from {0} to {1}. Exception {2}{3}",
158 thisRegion.RegionName, region.RegionName, uri, e.Message), e); 158// thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace);
159 159
160 return false; 160 return false;
161 } 161 }
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
index b7e95c4..1f14b32 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs
@@ -313,6 +313,17 @@ namespace OpenSim.Services.Connectors
313 { 313 {
314 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]); 314 pinfo = new PresenceInfo((Dictionary<string, object>)replyData["result"]);
315 } 315 }
316 else
317 {
318 if (replyData["result"].ToString() == "null")
319 return null;
320
321 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply (result not dictionary) received from presence server when querying for sessionID {0}", sessionID.ToString());
322 }
323 }
324 else
325 {
326 m_log.DebugFormat("[PRESENCE CONNECTOR]: Invalid reply received from presence server when querying for sessionID {0}", sessionID.ToString());
316 } 327 }
317 328
318 return pinfo; 329 return pinfo;
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
index 3bd11d9..c402907 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs
@@ -102,6 +102,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector"); 102 m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector");
103 } 103 }
104 104
105 public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
106 {
107 realID = UUID.Zero;
108 return Authenticate(principalID, password, lifetime);
109 }
110
105 public string Authenticate(UUID principalID, string password, int lifetime) 111 public string Authenticate(UUID principalID, string password, int lifetime)
106 { 112 {
107 NameValueCollection requestArgs = new NameValueCollection 113 NameValueCollection requestArgs = new NameValueCollection
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
index a397740..a52dd6c 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs
@@ -152,7 +152,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
152 // <param name=""></param> 152 // <param name=""></param>
153 public bool SetAppearance(UUID userID, AvatarAppearance appearance) 153 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
154 { 154 {
155 OSDMap map = appearance.Pack(); 155 EntityTransferContext ctx = new EntityTransferContext();
156 OSDMap map = appearance.Pack(ctx);
156 if (map == null) 157 if (map == null)
157 { 158 {
158 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID); 159 m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index b031f21..bd35c6f 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
31using System.IO; 33using System.IO;
32using System.Net; 34using System.Net;
33using System.Reflection; 35using System.Reflection;
@@ -100,6 +102,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
100 102
101 public string RegisterRegion(UUID scopeID, GridRegion regionInfo) 103 public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
102 { 104 {
105 IPEndPoint ext = regionInfo.ExternalEndPoint;
106 if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint";
107 // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service
108// Scene scene;
109// if (m_scenes.TryGetValue(regionInfo.RegionID, out scene))
110// UploadMapTile(scene);
111// else
112// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
113
103 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); 114 Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
104 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight); 115 Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
105 116
@@ -108,7 +119,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
108 { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, 119 { "ServerURI", OSD.FromString(regionInfo.ServerURI) },
109 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, 120 { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) },
110 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, 121 { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) },
111 { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, 122 { "ExternalAddress", OSD.FromString(ext.Address.ToString()) },
112 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, 123 { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) },
113 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, 124 { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) },
114 { "Access", OSD.FromInteger(regionInfo.Access) }, 125 { "Access", OSD.FromInteger(regionInfo.Access) },
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
index 698c4c0..563a1e7 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs
@@ -196,6 +196,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
196 m_accountCache.Remove(userID); 196 m_accountCache.Remove(userID);
197 } 197 }
198 198
199 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
200 {
201 return null;
202 }
203
199 public bool StoreUserAccount(UserAccount data) 204 public bool StoreUserAccount(UserAccount data)
200 { 205 {
201// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); 206// m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name);
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index cea870b..5dc4897 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -98,13 +98,13 @@ namespace OpenSim.Services.Connectors.Simulation
98 args["teleport_flags"] = OSD.FromString(flags.ToString()); 98 args["teleport_flags"] = OSD.FromString(flags.ToString());
99 } 99 }
100 100
101 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 101 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason)
102 { 102 {
103 string tmp = String.Empty; 103 string tmp = String.Empty;
104 return CreateAgent(source, destination, aCircuit, flags, out tmp, out reason); 104 return CreateAgent(source, destination, aCircuit, flags, ctx, out tmp, out reason);
105 } 105 }
106 106
107 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) 107 public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string myipaddress, out string reason)
108 { 108 {
109 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); 109 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
110 reason = String.Empty; 110 reason = String.Empty;
@@ -112,6 +112,7 @@ namespace OpenSim.Services.Connectors.Simulation
112 112
113 if (destination == null) 113 if (destination == null)
114 { 114 {
115 reason = "Destination not found";
115 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null"); 116 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
116 return false; 117 return false;
117 } 118 }
@@ -120,7 +121,8 @@ namespace OpenSim.Services.Connectors.Simulation
120 121
121 try 122 try
122 { 123 {
123 OSDMap args = aCircuit.PackAgentCircuitData(); 124 OSDMap args = aCircuit.PackAgentCircuitData(ctx);
125 args["context"] = ctx.Pack();
124 PackData(args, source, aCircuit, destination, flags); 126 PackData(args, source, aCircuit, destination, flags);
125 127
126 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); 128 OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000);
@@ -171,9 +173,9 @@ namespace OpenSim.Services.Connectors.Simulation
171 /// <summary> 173 /// <summary>
172 /// Send complete data about an agent in this region to a neighbor 174 /// Send complete data about an agent in this region to a neighbor
173 /// </summary> 175 /// </summary>
174 public bool UpdateAgent(GridRegion destination, AgentData data) 176 public bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx)
175 { 177 {
176 return UpdateAgent(destination, (IAgentData)data, 200000); // yes, 200 seconds 178 return UpdateAgent(destination, (IAgentData)data, ctx, 200000); // yes, 200 seconds
177 } 179 }
178 180
179 private ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>(); 181 private ExpiringCache<string, bool> _failedSims = new ExpiringCache<string, bool>();
@@ -234,7 +236,8 @@ namespace OpenSim.Services.Connectors.Simulation
234 } 236 }
235 } 237 }
236 238
237 success = UpdateAgent(destination, (IAgentData)pos, 10000); 239 EntityTransferContext ctx = new EntityTransferContext(); // Dummy, not needed for position
240 success = UpdateAgent(destination, (IAgentData)pos, ctx, 10000);
238 } 241 }
239 // we get here iff success == false 242 // we get here iff success == false
240 // blacklist sim for 2 minutes 243 // blacklist sim for 2 minutes
@@ -249,7 +252,7 @@ namespace OpenSim.Services.Connectors.Simulation
249 /// <summary> 252 /// <summary>
250 /// This is the worker function to send AgentData to a neighbor region 253 /// This is the worker function to send AgentData to a neighbor region
251 /// </summary> 254 /// </summary>
252 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) 255 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, EntityTransferContext ctx, int timeout)
253 { 256 {
254 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); 257 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI);
255 258
@@ -258,12 +261,13 @@ namespace OpenSim.Services.Connectors.Simulation
258 261
259 try 262 try
260 { 263 {
261 OSDMap args = cAgentData.Pack(); 264 OSDMap args = cAgentData.Pack(ctx);
262 265
263 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); 266 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
264 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); 267 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
265 args["destination_name"] = OSD.FromString(destination.RegionName); 268 args["destination_name"] = OSD.FromString(destination.RegionName);
266 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); 269 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
270 args["context"] = ctx.Pack();
267 271
268 OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout); 272 OSDMap result = WebUtil.PutToServiceCompressed(uri, args, timeout);
269 if (result["Success"].AsBoolean()) 273 if (result["Success"].AsBoolean())
@@ -306,6 +310,8 @@ namespace OpenSim.Services.Connectors.Simulation
306 request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin)); 310 request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin));
307 request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax)); 311 request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax));
308 312
313 request.Add("context", ctx.Pack());
314
309 OSDArray features = new OSDArray(); 315 OSDArray features = new OSDArray();
310 foreach (UUID feature in featuresAvailable) 316 foreach (UUID feature in featuresAvailable)
311 features.Add(OSD.FromString(feature.ToString())); 317 features.Add(OSD.FromString(feature.ToString()));
@@ -345,8 +351,6 @@ namespace OpenSim.Services.Connectors.Simulation
345 ctx.OutboundVersion = float.Parse(parts[1]); 351 ctx.OutboundVersion = float.Parse(parts[1]);
346 } 352 }
347 } 353 }
348 if (data.ContainsKey("variable_wearables_count_supported"))
349 ctx.VariableWearablesSupported = true;
350 354
351 m_log.DebugFormat( 355 m_log.DebugFormat(
352 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}", 356 "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}",
@@ -379,7 +383,6 @@ namespace OpenSim.Services.Connectors.Simulation
379 return false; 383 return false;
380 } 384 }
381 385
382
383 featuresAvailable.Clear(); 386 featuresAvailable.Clear();
384 387
385 if (result.ContainsKey("features")) 388 if (result.ContainsKey("features"))
@@ -390,6 +393,10 @@ namespace OpenSim.Services.Connectors.Simulation
390 featuresAvailable.Add(new UUID(o.AsString())); 393 featuresAvailable.Add(new UUID(o.AsString()));
391 } 394 }
392 395
396 // Version stuff
397 if (ctx.OutboundVersion < 0.4)
398 ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES;
399
393 return success; 400 return success;
394 } 401 }
395 catch (Exception e) 402 catch (Exception e)
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
index c21db54..3de0a20 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs
@@ -195,6 +195,11 @@ namespace OpenSim.Services.Connectors
195 { 195 {
196 } 196 }
197 197
198 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
199 {
200 return null; // Not implemented for regions
201 }
202
198 public virtual bool StoreUserAccount(UserAccount data) 203 public virtual bool StoreUserAccount(UserAccount data)
199 { 204 {
200 Dictionary<string, object> sendData = new Dictionary<string, object>(); 205 Dictionary<string, object> sendData = new Dictionary<string, object>();
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 8807397..53805d0 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Services.GridService
57 protected bool m_AllowDuplicateNames = false; 57 protected bool m_AllowDuplicateNames = false;
58 protected bool m_AllowHypergridMapSearch = false; 58 protected bool m_AllowHypergridMapSearch = false;
59 59
60
60 protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; 61 protected bool m_SuppressVarregionOverlapCheckOnRegistration = false;
61 62
62 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>(); 63 private static Dictionary<string,object> m_ExtraFeatures = new Dictionary<string, object>();
@@ -155,9 +156,9 @@ namespace OpenSim.Services.GridService
155 156
156 if (loginConfig == null || gridConfig == null) 157 if (loginConfig == null || gridConfig == null)
157 return; 158 return;
158 159
159 string configVal; 160 string configVal;
160 161
161 configVal = loginConfig.GetString("SearchURL", string.Empty); 162 configVal = loginConfig.GetString("SearchURL", string.Empty);
162 if (!string.IsNullOrEmpty(configVal)) 163 if (!string.IsNullOrEmpty(configVal))
163 m_ExtraFeatures["search-server-url"] = configVal; 164 m_ExtraFeatures["search-server-url"] = configVal;
@@ -202,14 +203,10 @@ namespace OpenSim.Services.GridService
202 return "Invalid RegionID - cannot be zero UUID"; 203 return "Invalid RegionID - cannot be zero UUID";
203 204
204 String reason = "Region overlaps another region"; 205 String reason = "Region overlaps another region";
205 RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); 206 // we should not need to check for overlaps
206 // If there is a conflicting region, if it has the same ID and same coordinates 207
207 // then it is a region re-registering (permissions and ownership checked later). 208 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
208 if ((region != null) 209 if ((region != null) && (region.RegionID != regionInfos.RegionID))
209 && ( (region.coordX != regionInfos.RegionCoordX)
210 || (region.coordY != regionInfos.RegionCoordY)
211 || (region.RegionID != regionInfos.RegionID) )
212 )
213 { 210 {
214 // If not same ID and same coordinates, this new region has conflicts and can't be registered. 211 // If not same ID and same coordinates, this new region has conflicts and can't be registered.
215 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); 212 m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason);
@@ -463,7 +460,7 @@ namespace OpenSim.Services.GridService
463 460
464 int flags = Convert.ToInt32(region.Data["flags"]); 461 int flags = Convert.ToInt32(region.Data["flags"]);
465 462
466 if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) 463 if ((!m_DeleteOnUnregister) || ((flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0))
467 { 464 {
468 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; 465 flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline;
469 region.Data["flags"] = flags.ToString(); 466 region.Data["flags"] = flags.ToString();
@@ -478,7 +475,6 @@ namespace OpenSim.Services.GridService
478 } 475 }
479 476
480 return true; 477 return true;
481
482 } 478 }
483 479
484 return m_Database.Delete(regionID); 480 return m_Database.Delete(regionID);
@@ -491,10 +487,8 @@ namespace OpenSim.Services.GridService
491 487
492 if (region != null) 488 if (region != null)
493 { 489 {
494 // Not really? Maybe?
495 // The adjacent regions are presumed to be the same size as the current region
496 List<RegionData> rdatas = m_Database.Get( 490 List<RegionData> rdatas = m_Database.Get(
497 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, 491 region.posX - 1, region.posY - 1,
498 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); 492 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
499 493
500 foreach (RegionData rdata in rdatas) 494 foreach (RegionData rdata in rdatas)
@@ -537,6 +531,7 @@ namespace OpenSim.Services.GridService
537 // be the base coordinate of the region. 531 // be the base coordinate of the region.
538 // The snapping is technically unnecessary but is harmless because regions are always 532 // The snapping is technically unnecessary but is harmless because regions are always
539 // multiples of the legacy region size (256). 533 // multiples of the legacy region size (256).
534
540 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 535 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
541 { 536 {
542 uint regionX = Util.WorldToRegionLoc((uint)x); 537 uint regionX = Util.WorldToRegionLoc((uint)x);
@@ -872,7 +867,9 @@ namespace OpenSim.Services.GridService
872 return; 867 return;
873 } 868 }
874 869
870
875 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); 871 RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero);
872
876 if (region == null) 873 if (region == null)
877 { 874 {
878 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); 875 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@@ -889,7 +886,7 @@ namespace OpenSim.Services.GridService
889 ConsoleDisplayList dispList = new ConsoleDisplayList(); 886 ConsoleDisplayList dispList = new ConsoleDisplayList();
890 dispList.AddRow("Region Name", r.RegionName); 887 dispList.AddRow("Region Name", r.RegionName);
891 dispList.AddRow("Region ID", r.RegionID); 888 dispList.AddRow("Region ID", r.RegionID);
892 dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); 889 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
893 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); 890 dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
894 dispList.AddRow("URI", r.Data["serverURI"]); 891 dispList.AddRow("URI", r.Data["serverURI"]);
895 dispList.AddRow("Owner ID", r.Data["owner_uuid"]); 892 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs
index 9d016fc..2af617a 100644
--- a/OpenSim/Services/GridService/HypergridLinker.cs
+++ b/OpenSim/Services/GridService/HypergridLinker.cs
@@ -231,8 +231,7 @@ namespace OpenSim.Services.GridService
231 { 231 {
232 regionName = parts[2]; 232 regionName = parts[2];
233 } 233 }
234 234
235
236 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); 235 bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason);
237 if (success) 236 if (success)
238 { 237 {
@@ -379,8 +378,7 @@ namespace OpenSim.Services.GridService
379 region = m_GridService.GetRegionByUUID(scopeID, regionID); 378 region = m_GridService.GetRegionByUUID(scopeID, regionID);
380 if (region != null) 379 if (region != null)
381 { 380 {
382 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", 381 m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates <{0},{1}>", Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
383 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
384 regInfo = region; 382 regInfo = region;
385 return true; 383 return true;
386 } 384 }
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 8e10125..9643a8b 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -459,7 +459,7 @@ namespace OpenSim.Services.HypergridService
459 true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 459 true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
460 return false; 460 return false;
461 461
462 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason); 462 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, ctx, out reason);
463 } 463 }
464 464
465 protected bool Authenticate(AgentCircuitData aCircuit) 465 protected bool Authenticate(AgentCircuitData aCircuit)
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
index fa7dd0b..6c3c655 100644
--- a/OpenSim/Services/HypergridService/UserAccountCache.cs
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -90,6 +90,11 @@ namespace OpenSim.Services.HypergridService
90 return null; 90 return null;
91 } 91 }
92 92
93 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
94 {
95 return null;
96 }
97
93 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 98 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
94 { 99 {
95 return null; 100 return null;
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index c65122a..317d006 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -281,7 +281,9 @@ namespace OpenSim.Services.HypergridService
281 } 281 }
282 else 282 else
283 { 283 {
284 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); 284 //TODO: Should there not be a call to QueryAccess here?
285 EntityTransferContext ctx = new EntityTransferContext();
286 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, ctx, out myExternalIP, out reason);
285 } 287 }
286 288
287 if (!success) 289 if (!success)
diff --git a/OpenSim/Services/Interfaces/IAttachmentsService.cs b/OpenSim/Services/Interfaces/IAttachmentsService.cs
new file mode 100644
index 0000000..7d33662
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IAttachmentsService.cs
@@ -0,0 +1,38 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using Nini.Config;
30
31namespace OpenSim.Services.Interfaces
32{
33 public interface IAttachmentsService
34 {
35 string Get(string id);
36 void Store(string id, string data);
37 }
38}
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs
index cee8bc0..cdcfad9 100644
--- a/OpenSim/Services/Interfaces/IAuthenticationService.cs
+++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs
@@ -67,6 +67,7 @@ namespace OpenSim.Services.Interfaces
67 // various services. 67 // various services.
68 // 68 //
69 string Authenticate(UUID principalID, string password, int lifetime); 69 string Authenticate(UUID principalID, string password, int lifetime);
70 string Authenticate(UUID principalID, string password, int lifetime, out UUID realID);
70 71
71 ////////////////////////////////////////////////////// 72 //////////////////////////////////////////////////////
72 // Verification 73 // Verification
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index 892e0b4..99b71b9 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -150,7 +150,8 @@ namespace OpenSim.Services.Interfaces
150 // Wearables 150 // Wearables
151 Data["AvatarHeight"] = appearance.AvatarHeight.ToString(); 151 Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
152 152
153 for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++) 153 // TODO: With COF, is this even needed?
154 for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
154 { 155 {
155 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++) 156 for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
156 { 157 {
@@ -211,8 +212,8 @@ namespace OpenSim.Services.Interfaces
211 float h = float.Parse(Data["AvatarHeight"]); 212 float h = float.Parse(Data["AvatarHeight"]);
212 if( h == 0f) 213 if( h == 0f)
213 h = 1.9f; 214 h = 1.9f;
214 215 appearance.SetSize(new Vector3(0.45f, 0.6f, h ));
215 appearance.AvatarHeight = h; 216// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
216 } 217 }
217 218
218 // Legacy Wearables 219 // Legacy Wearables
@@ -287,11 +288,10 @@ namespace OpenSim.Services.Interfaces
287 //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT]; 288 //byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
288 289
289 //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++) 290 //for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
290
291 byte[] binary = new byte[vps.Length]; 291 byte[] binary = new byte[vps.Length];
292 292
293 for (int i = 0; i < vps.Length; i++) 293 for (int i = 0; i < vps.Length; i++)
294 binary[i] = (byte)Convert.ToInt32(vps[i]); 294 binary[i] = (byte)Convert.ToInt32(vps[i]);
295 295
296 appearance.VisualParams = binary; 296 appearance.VisualParams = binary;
297 } 297 }
@@ -357,6 +357,7 @@ namespace OpenSim.Services.Interfaces
357 appearance.Wearables[AvatarWearable.EYES].Wear( 357 appearance.Wearables[AvatarWearable.EYES].Wear(
358 AvatarWearable.DefaultWearables[ 358 AvatarWearable.DefaultWearables[
359 AvatarWearable.EYES][0]); 359 AvatarWearable.EYES][0]);
360
360 } 361 }
361 catch 362 catch
362 { 363 {
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index f5f1f75..63c6e5f 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -159,13 +159,24 @@ namespace OpenSim.Services.Interfaces
159 } 159 }
160 } 160 }
161 set { 161 set {
162 if (value.EndsWith("/")) { 162 if ( value == null)
163 {
164 m_serverURI = String.Empty;
165 return;
166 }
167
168 if ( value.EndsWith("/") )
169 {
170
163 m_serverURI = value; 171 m_serverURI = value;
164 } else { 172 }
173 else
174 {
165 m_serverURI = value + '/'; 175 m_serverURI = value + '/';
166 } 176 }
167 } 177 }
168 } 178 }
179
169 protected string m_serverURI; 180 protected string m_serverURI;
170 181
171 /// <summary> 182 /// <summary>
@@ -358,6 +369,13 @@ namespace OpenSim.Services.Interfaces
358 if (kvp.ContainsKey("regionName")) 369 if (kvp.ContainsKey("regionName"))
359 RegionName = (string)kvp["regionName"]; 370 RegionName = (string)kvp["regionName"];
360 371
372 if (kvp.ContainsKey("access"))
373 {
374 byte access = Convert.ToByte((string)kvp["access"]);
375 Access = access;
376 Maturity = (int)Util.ConvertAccessLevelToMaturity(access);
377 }
378
361 if (kvp.ContainsKey("flags") && kvp["flags"] != null) 379 if (kvp.ContainsKey("flags") && kvp["flags"] != null)
362 RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]); 380 RegionFlags = (OpenSim.Framework.RegionFlags?)Convert.ToInt32((string)kvp["flags"]);
363 381
@@ -394,9 +412,6 @@ namespace OpenSim.Services.Interfaces
394 if (kvp.ContainsKey("parcelMapTexture")) 412 if (kvp.ContainsKey("parcelMapTexture"))
395 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage); 413 UUID.TryParse((string)kvp["parcelMapTexture"], out ParcelImage);
396 414
397 if (kvp.ContainsKey("access"))
398 Access = Byte.Parse((string)kvp["access"]);
399
400 if (kvp.ContainsKey("regionSecret")) 415 if (kvp.ContainsKey("regionSecret"))
401 RegionSecret =(string)kvp["regionSecret"]; 416 RegionSecret =(string)kvp["regionSecret"];
402 417
@@ -500,9 +515,13 @@ namespace OpenSim.Services.Interfaces
500 } 515 }
501 catch (SocketException e) 516 catch (SocketException e)
502 { 517 {
503 throw new Exception( 518 /*throw new Exception(
504 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + 519 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
505 e + "' attached to this exception", e); 520 e + "' attached to this exception", e);*/
521 // Don't throw a fatal exception here, instead, return Null and handle it in the caller.
522 // Reason is, on systems such as OSgrid it has occured that known hostnames stop
523 // resolving and thus make surrounding regions crash out with this exception.
524 return null;
506 } 525 }
507 526
508 return new IPEndPoint(ia, m_internalEndPoint.Port); 527 return new IPEndPoint(ia, m_internalEndPoint.Port);
@@ -526,4 +545,4 @@ namespace OpenSim.Services.Interfaces
526 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); } 545 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
527 } 546 }
528 } 547 }
529} \ No newline at end of file 548}
diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs
index ee9b0b1..7c44cd8 100644
--- a/OpenSim/Services/Interfaces/ILoginService.cs
+++ b/OpenSim/Services/Interfaces/ILoginService.cs
@@ -47,8 +47,8 @@ namespace OpenSim.Services.Interfaces
47 47
48 public interface ILoginService 48 public interface ILoginService
49 { 49 {
50 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, 50 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
51 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP); 51 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient);
52 Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP); 52 Hashtable SetLevel(string firstName, string lastName, string passwd, int level, IPEndPoint clientIP);
53 } 53 }
54 54
diff --git a/OpenSim/Services/Interfaces/IMapImageService.cs b/OpenSim/Services/Interfaces/IMapImageService.cs
index 78daa5f..b8d45dd 100644
--- a/OpenSim/Services/Interfaces/IMapImageService.cs
+++ b/OpenSim/Services/Interfaces/IMapImageService.cs
@@ -34,8 +34,8 @@ namespace OpenSim.Services.Interfaces
34 public interface IMapImageService 34 public interface IMapImageService
35 { 35 {
36 //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY); 36 //List<MapBlockData> GetMapBlocks(UUID scopeID, int minX, int minY, int maxX, int maxY);
37 bool AddMapTile(int x, int y, byte[] imageData, out string reason); 37 bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason);
38 bool RemoveMapTile(int x, int y, out string reason); 38 bool RemoveMapTile(int x, int y, UUID scopeID, out string reason);
39 byte[] GetMapTile(string fileName, out string format); 39 byte[] GetMapTile(string fileName, UUID scopeID, out string format);
40 } 40 }
41} 41}
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 8a25509..d89f6ff 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -34,20 +34,6 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
34 34
35namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
36{ 36{
37 public class EntityTransferContext
38 {
39 public EntityTransferContext()
40 {
41 InboundVersion = VersionInfo.SimulationServiceVersionAcceptedMax;
42 OutboundVersion = VersionInfo.SimulationServiceVersionSupportedMax;
43 VariableWearablesSupported = false;
44 }
45
46 public float InboundVersion { get; set; }
47 public float OutboundVersion { get; set; }
48 public bool VariableWearablesSupported { get; set; }
49 }
50
51 public interface ISimulationService 37 public interface ISimulationService
52 { 38 {
53 /// <summary> 39 /// <summary>
@@ -74,7 +60,7 @@ namespace OpenSim.Services.Interfaces
74 /// <param name="aCircuit"></param> 60 /// <param name="aCircuit"></param>
75 /// <param name="flags"></param> 61 /// <param name="flags"></param>
76 /// <param name="reason">Reason message in the event of a failure.</param> 62 /// <param name="reason">Reason message in the event of a failure.</param>
77 bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason); 63 bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason);
78 64
79 /// <summary> 65 /// <summary>
80 /// Full child agent update. 66 /// Full child agent update.
@@ -82,7 +68,7 @@ namespace OpenSim.Services.Interfaces
82 /// <param name="regionHandle"></param> 68 /// <param name="regionHandle"></param>
83 /// <param name="data"></param> 69 /// <param name="data"></param>
84 /// <returns></returns> 70 /// <returns></returns>
85 bool UpdateAgent(GridRegion destination, AgentData data); 71 bool UpdateAgent(GridRegion destination, AgentData data, EntityTransferContext ctx);
86 72
87 /// <summary> 73 /// <summary>
88 /// Short child agent update, mostly for position. 74 /// Short child agent update, mostly for position.
@@ -100,6 +86,7 @@ namespace OpenSim.Services.Interfaces
100 /// <param name="agentHomeURI">The visitor's Home URI. Will be missing (null) in older OpenSims.</param> 86 /// <param name="agentHomeURI">The visitor's Home URI. Will be missing (null) in older OpenSims.</param>
101 /// <param name="viaTeleport">True: via teleport; False: via cross (walking)</param> 87 /// <param name="viaTeleport">True: via teleport; False: via cross (walking)</param>
102 /// <param name="position">Position in the region</param> 88 /// <param name="position">Position in the region</param>
89
103 /// <param name="sversion"> 90 /// <param name="sversion">
104 /// Version that the requesting simulator is runing. If null then no version check is carried out. 91 /// Version that the requesting simulator is runing. If null then no version check is carried out.
105 /// </param> 92 /// </param>
diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs
index 2f7702c..1814699 100644
--- a/OpenSim/Services/Interfaces/IUserAccountService.cs
+++ b/OpenSim/Services/Interfaces/IUserAccountService.cs
@@ -91,6 +91,7 @@ namespace OpenSim.Services.Interfaces
91 public int UserLevel; 91 public int UserLevel;
92 public int UserFlags; 92 public int UserFlags;
93 public string UserTitle; 93 public string UserTitle;
94 public string UserCountry;
94 public Boolean LocalToGrid = true; 95 public Boolean LocalToGrid = true;
95 96
96 public Dictionary<string, object> ServiceURLs; 97 public Dictionary<string, object> ServiceURLs;
@@ -120,6 +121,8 @@ namespace OpenSim.Services.Interfaces
120 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString()); 121 UserFlags = Convert.ToInt32(kvp["UserFlags"].ToString());
121 if (kvp.ContainsKey("UserTitle")) 122 if (kvp.ContainsKey("UserTitle"))
122 UserTitle = kvp["UserTitle"].ToString(); 123 UserTitle = kvp["UserTitle"].ToString();
124 if (kvp.ContainsKey("UserCountry"))
125 UserCountry = kvp["UserCountry"].ToString();
123 if (kvp.ContainsKey("LocalToGrid")) 126 if (kvp.ContainsKey("LocalToGrid"))
124 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid); 127 Boolean.TryParse(kvp["LocalToGrid"].ToString(), out LocalToGrid);
125 128
@@ -155,6 +158,7 @@ namespace OpenSim.Services.Interfaces
155 result["UserLevel"] = UserLevel.ToString(); 158 result["UserLevel"] = UserLevel.ToString();
156 result["UserFlags"] = UserFlags.ToString(); 159 result["UserFlags"] = UserFlags.ToString();
157 result["UserTitle"] = UserTitle; 160 result["UserTitle"] = UserTitle;
161 result["UserCountry"] = UserCountry;
158 result["LocalToGrid"] = LocalToGrid.ToString(); 162 result["LocalToGrid"] = LocalToGrid.ToString();
159 163
160 string str = string.Empty; 164 string str = string.Empty;
@@ -182,6 +186,7 @@ namespace OpenSim.Services.Interfaces
182 /// <param name="query"></param> 186 /// <param name="query"></param>
183 /// <returns></returns> 187 /// <returns></returns>
184 List<UserAccount> GetUserAccounts(UUID scopeID, string query); 188 List<UserAccount> GetUserAccounts(UUID scopeID, string query);
189 List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where);
185 190
186 /// <summary> 191 /// <summary>
187 /// Store the data given, wich replaces the stored data, therefore must be complete. 192 /// Store the data given, wich replaces the stored data, therefore must be complete.
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index c3756d0..0f57c2e 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Services.LLLoginService
55 public static LLFailedLoginResponse InventoryProblem; 55 public static LLFailedLoginResponse InventoryProblem;
56 public static LLFailedLoginResponse DeadRegionProblem; 56 public static LLFailedLoginResponse DeadRegionProblem;
57 public static LLFailedLoginResponse LoginBlockedProblem; 57 public static LLFailedLoginResponse LoginBlockedProblem;
58 public static LLFailedLoginResponse UnverifiedAccountProblem;
58 public static LLFailedLoginResponse AlreadyLoggedInProblem; 59 public static LLFailedLoginResponse AlreadyLoggedInProblem;
59 public static LLFailedLoginResponse InternalError; 60 public static LLFailedLoginResponse InternalError;
60 61
@@ -75,6 +76,10 @@ namespace OpenSim.Services.LLLoginService
75 LoginBlockedProblem = new LLFailedLoginResponse("presence", 76 LoginBlockedProblem = new LLFailedLoginResponse("presence",
76 "Logins are currently restricted. Please try again later.", 77 "Logins are currently restricted. Please try again later.",
77 "false"); 78 "false");
79 UnverifiedAccountProblem = new LLFailedLoginResponse("presence",
80 "Your account has not yet been verified. Please check " +
81 "your email and click the provided link.",
82 "false");
78 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", 83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
79 "You appear to be already logged in. " + 84 "You appear to be already logged in. " +
80 "If this is not the case please wait for your session to timeout. " + 85 "If this is not the case please wait for your session to timeout. " +
@@ -145,6 +150,7 @@ namespace OpenSim.Services.LLLoginService
145 private UUID agentID; 150 private UUID agentID;
146 private UUID sessionID; 151 private UUID sessionID;
147 private UUID secureSessionID; 152 private UUID secureSessionID;
153 private UUID realID;
148 154
149 // Login Flags 155 // Login Flags
150 private string dst; 156 private string dst;
@@ -228,8 +234,9 @@ namespace OpenSim.Services.LLLoginService
228 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, 234 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
229 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, 235 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
230 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message, 236 string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
231 GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL, string currency, 237
232 string DSTZone, string destinationsURL, string avatarsURL, string classifiedFee, int maxAgentGroups) 238 GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency,
239 string DSTZone, string destinationsURL, string avatarsURL, UUID realID, string classifiedFee,int maxAgentGroups)
233 : this() 240 : this()
234 { 241 {
235 FillOutInventoryData(invSkel, libService); 242 FillOutInventoryData(invSkel, libService);
@@ -242,6 +249,7 @@ namespace OpenSim.Services.LLLoginService
242 AgentID = account.PrincipalID; 249 AgentID = account.PrincipalID;
243 SessionID = aCircuit.SessionID; 250 SessionID = aCircuit.SessionID;
244 SecureSessionID = aCircuit.SecureSessionID; 251 SecureSessionID = aCircuit.SecureSessionID;
252 RealID = realID;
245 Message = message; 253 Message = message;
246 BuddList = ConvertFriendListItem(friendsList); 254 BuddList = ConvertFriendListItem(friendsList);
247 StartLocation = where; 255 StartLocation = where;
@@ -383,6 +391,7 @@ namespace OpenSim.Services.LLLoginService
383 private void FillOutRegionData(GridRegion destination) 391 private void FillOutRegionData(GridRegion destination)
384 { 392 {
385 IPEndPoint endPoint = destination.ExternalEndPoint; 393 IPEndPoint endPoint = destination.ExternalEndPoint;
394 if (endPoint == null) return;
386 SimAddress = endPoint.Address.ToString(); 395 SimAddress = endPoint.Address.ToString();
387 SimPort = (uint)endPoint.Port; 396 SimPort = (uint)endPoint.Port;
388 RegionX = (uint)destination.RegionLocX; 397 RegionX = (uint)destination.RegionLocX;
@@ -473,6 +482,7 @@ namespace OpenSim.Services.LLLoginService
473 SessionID = UUID.Random(); 482 SessionID = UUID.Random();
474 SecureSessionID = UUID.Random(); 483 SecureSessionID = UUID.Random();
475 AgentID = UUID.Random(); 484 AgentID = UUID.Random();
485 RealID = UUID.Zero;
476 486
477 Hashtable InitialOutfitHash = new Hashtable(); 487 Hashtable InitialOutfitHash = new Hashtable();
478 InitialOutfitHash["folder_name"] = "Nightclub Female"; 488 InitialOutfitHash["folder_name"] = "Nightclub Female";
@@ -518,6 +528,7 @@ namespace OpenSim.Services.LLLoginService
518 responseData["http_port"] = (Int32)SimHttpPort; 528 responseData["http_port"] = (Int32)SimHttpPort;
519 529
520 responseData["agent_id"] = AgentID.ToString(); 530 responseData["agent_id"] = AgentID.ToString();
531 responseData["real_id"] = RealID.ToString();
521 responseData["session_id"] = SessionID.ToString(); 532 responseData["session_id"] = SessionID.ToString();
522 responseData["secure_session_id"] = SecureSessionID.ToString(); 533 responseData["secure_session_id"] = SecureSessionID.ToString();
523 responseData["circuit_code"] = CircuitCode; 534 responseData["circuit_code"] = CircuitCode;
@@ -613,6 +624,7 @@ namespace OpenSim.Services.LLLoginService
613 map["sim_ip"] = OSD.FromString(SimAddress); 624 map["sim_ip"] = OSD.FromString(SimAddress);
614 625
615 map["agent_id"] = OSD.FromUUID(AgentID); 626 map["agent_id"] = OSD.FromUUID(AgentID);
627 map["real_id"] = OSD.FromUUID(RealID);
616 map["session_id"] = OSD.FromUUID(SessionID); 628 map["session_id"] = OSD.FromUUID(SessionID);
617 map["secure_session_id"] = OSD.FromUUID(SecureSessionID); 629 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
618 map["circuit_code"] = OSD.FromInteger(CircuitCode); 630 map["circuit_code"] = OSD.FromInteger(CircuitCode);
@@ -924,6 +936,12 @@ namespace OpenSim.Services.LLLoginService
924 set { secureSessionID = value; } 936 set { secureSessionID = value; }
925 } 937 }
926 938
939 public UUID RealID
940 {
941 get { return realID; }
942 set { realID = value; }
943 }
944
927 public Int32 CircuitCode 945 public Int32 CircuitCode
928 { 946 {
929 get { return circuitCode; } 947 get { return circuitCode; }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 0b38738..6681f1a 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -77,6 +77,8 @@ namespace OpenSim.Services.LLLoginService
77 protected string m_GatekeeperURL; 77 protected string m_GatekeeperURL;
78 protected bool m_AllowRemoteSetLoginLevel; 78 protected bool m_AllowRemoteSetLoginLevel;
79 protected string m_MapTileURL; 79 protected string m_MapTileURL;
80 protected string m_ProfileURL;
81 protected string m_OpenIDURL;
80 protected string m_SearchURL; 82 protected string m_SearchURL;
81 protected string m_Currency; 83 protected string m_Currency;
82 protected string m_ClassifiedFee; 84 protected string m_ClassifiedFee;
@@ -117,6 +119,8 @@ namespace OpenSim.Services.LLLoginService
117 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI", 119 m_GatekeeperURL = Util.GetConfigVarFromSections<string>(config, "GatekeeperURI",
118 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty); 120 new string[] { "Startup", "Hypergrid", "LoginService" }, String.Empty);
119 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); 121 m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty);
122 m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty);
123 m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty);
120 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); 124 m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty);
121 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); 125 m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty);
122 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty); 126 m_ClassifiedFee = m_LoginServerConfig.GetString("ClassifiedFee", string.Empty);
@@ -155,7 +159,8 @@ namespace OpenSim.Services.LLLoginService
155 Object[] args = new Object[] { config }; 159 Object[] args = new Object[] { config };
156 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 160 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
157 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args); 161 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
158 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 162 Object[] authArgs = new Object[] { config, m_UserAccountService };
163 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, authArgs);
159 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 164 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
160 165
161 if (gridService != string.Empty) 166 if (gridService != string.Empty)
@@ -261,14 +266,18 @@ namespace OpenSim.Services.LLLoginService
261 } 266 }
262 267
263 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, 268 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID,
264 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP) 269 string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, bool LibOMVclient)
265 { 270 {
266 bool success = false; 271 bool success = false;
267 UUID session = UUID.Random(); 272 UUID session = UUID.Random();
273
268 string processedMessage; 274 string processedMessage;
269 275
270 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}", 276 if (clientVersion.Contains("Radegast"))
271 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0); 277 LibOMVclient = false;
278
279 m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} {1} at {2} using viewer {3}, channel {4}, IP {5}, Mac {6}, Id0 {7}, Possible LibOMVGridProxy: {8} ",
280 firstName, lastName, startLocation, clientVersion, channel, clientIP.Address.ToString(), mac, id0, LibOMVclient.ToString());
272 281
273 try 282 try
274 { 283 {
@@ -345,7 +354,8 @@ namespace OpenSim.Services.LLLoginService
345 if (!passwd.StartsWith("$1$")) 354 if (!passwd.StartsWith("$1$"))
346 passwd = "$1$" + Util.Md5Hash(passwd); 355 passwd = "$1$" + Util.Md5Hash(passwd);
347 passwd = passwd.Remove(0, 3); //remove $1$ 356 passwd = passwd.Remove(0, 3); //remove $1$
348 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 357 UUID realID;
358 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID);
349 UUID secureSession = UUID.Zero; 359 UUID secureSession = UUID.Zero;
350 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 360 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
351 { 361 {
@@ -512,11 +522,11 @@ namespace OpenSim.Services.LLLoginService
512 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName); 522 processedMessage = processedMessage.Replace("\\n", "\n").Replace("<USERNAME>", firstName + " " + lastName);
513 523
514 LLLoginResponse response 524 LLLoginResponse response
515 = new LLLoginResponse( 525 = new LLLoginResponse(
516 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, 526 account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
517 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP, 527 where, startLocation, position, lookAt, gestures, processedMessage, home, clientIP,
518 m_MapTileURL, m_SearchURL, m_Currency, m_DSTZone, 528 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone,
519 m_DestinationGuide, m_AvatarPicker, m_ClassifiedFee, m_MaxAgentGroups); 529 m_DestinationGuide, m_AvatarPicker, realID, m_ClassifiedFee,m_MaxAgentGroups);
520 530
521 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName); 531 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
522 532
@@ -989,7 +999,7 @@ namespace OpenSim.Services.LLLoginService
989 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason)) 999 region, aCircuit.AgentID, null, true, aCircuit.startpos, new List<UUID>(), ctx, out reason))
990 return false; 1000 return false;
991 1001
992 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, out reason); 1002 return simConnector.CreateAgent(null, region, aCircuit, (uint)flags, ctx, out reason);
993 } 1003 }
994 1004
995 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason) 1005 private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, IPEndPoint clientIP, out string reason)
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs
index a816411..6728752 100644
--- a/OpenSim/Services/MapImageService/MapImageService.cs
+++ b/OpenSim/Services/MapImageService/MapImageService.cs
@@ -69,6 +69,8 @@ namespace OpenSim.Services.MapImageService
69 private static bool m_Initialized = false; 69 private static bool m_Initialized = false;
70 private static string m_WaterTileFile = string.Empty; 70 private static string m_WaterTileFile = string.Empty;
71 private static Color m_Watercolor = Color.FromArgb(29, 71, 95); 71 private static Color m_Watercolor = Color.FromArgb(29, 71, 95);
72 private static Bitmap m_WaterBitmap = null;
73 private static byte[] m_WaterBytes = null;
72 74
73 public MapImageService(IConfigSource config) 75 public MapImageService(IConfigSource config)
74 { 76 {
@@ -91,6 +93,18 @@ namespace OpenSim.Services.MapImageService
91 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH); 93 Bitmap waterTile = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH);
92 FillImage(waterTile, m_Watercolor); 94 FillImage(waterTile, m_Watercolor);
93 waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg); 95 waterTile.Save(m_WaterTileFile, ImageFormat.Jpeg);
96 m_WaterBitmap = waterTile;
97 }
98
99 if (File.Exists(m_WaterTileFile))
100 {
101 m_WaterBitmap = new Bitmap(m_WaterTileFile);
102 using (MemoryStream ms = new MemoryStream())
103 {
104 m_WaterBitmap.Save(ms,ImageFormat.Jpeg);
105 ms.Seek(0, SeekOrigin.Begin);
106 m_WaterBytes = ms.ToArray();
107 }
94 } 108 }
95 } 109 }
96 } 110 }
@@ -98,10 +112,10 @@ namespace OpenSim.Services.MapImageService
98 112
99 #region IMapImageService 113 #region IMapImageService
100 114
101 public bool AddMapTile(int x, int y, byte[] imageData, out string reason) 115 public bool AddMapTile(int x, int y, byte[] imageData, UUID scopeID, out string reason)
102 { 116 {
103 reason = string.Empty; 117 reason = string.Empty;
104 string fileName = GetFileName(1, x, y); 118 string fileName = GetFileName(1, x, y, scopeID);
105 119
106 lock (m_Sync) 120 lock (m_Sync)
107 { 121 {
@@ -118,13 +132,13 @@ namespace OpenSim.Services.MapImageService
118 } 132 }
119 } 133 }
120 134
121 return UpdateMultiResolutionFilesAsync(x, y, out reason); 135 return UpdateMultiResolutionFiles(x, y, scopeID, out reason);
122 } 136 }
123 137
124 public bool RemoveMapTile(int x, int y, out string reason) 138 public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason)
125 { 139 {
126 reason = String.Empty; 140 reason = String.Empty;
127 string fileName = GetFileName(1, x, y); 141 string fileName = GetFileName(1, x, y, scopeID);
128 142
129 lock (m_Sync) 143 lock (m_Sync)
130 { 144 {
@@ -134,15 +148,16 @@ namespace OpenSim.Services.MapImageService
134 } 148 }
135 catch (Exception e) 149 catch (Exception e)
136 { 150 {
151
137 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e); 152 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to save delete file {0}: {1}", fileName, e);
138 reason = e.Message; 153 reason = e.Message;
139 return false; 154 return false;
140 } 155 }
141 } 156 }
142 157 return UpdateMultiResolutionFiles(x, y, scopeID, out reason);
143 return UpdateMultiResolutionFilesAsync(x, y, out reason);
144 } 158 }
145 159
160
146 // When large varregions start up, they can send piles of new map tiles. This causes 161 // When large varregions start up, they can send piles of new map tiles. This causes
147 // this multi-resolution routine to be called a zillion times an causes much CPU 162 // this multi-resolution routine to be called a zillion times an causes much CPU
148 // time to be spent creating multi-resolution tiles that will be replaced when 163 // time to be spent creating multi-resolution tiles that will be replaced when
@@ -151,23 +166,27 @@ namespace OpenSim.Services.MapImageService
151 { 166 {
152 public int xx; 167 public int xx;
153 public int yy; 168 public int yy;
154 public mapToMultiRez(int pX, int pY) 169 public UUID scopeID;
170 public mapToMultiRez(int pX, int pY, UUID pscopeID)
155 { 171 {
156 xx = pX; 172 xx = pX;
157 yy = pY; 173 yy = pY;
174 scopeID = pscopeID;
158 } 175 }
159 }; 176 };
160 private Queue<mapToMultiRez> multiRezToBuild = new Queue<mapToMultiRez>(); 177 private Queue<mapToMultiRez> multiRezToBuild = new Queue<mapToMultiRez>();
161 private bool UpdateMultiResolutionFilesAsync(int x, int y, out string reason) 178
179 private bool UpdateMultiResolutionFiles(int x, int y, UUID scopeID, out string reason)
162 { 180 {
163 reason = String.Empty; 181 reason = String.Empty;
182
164 lock (multiRezToBuild) 183 lock (multiRezToBuild)
165 { 184 {
166 // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y); 185 // m_log.DebugFormat("{0} UpdateMultiResolutionFilesAsync: scheduling update for <{1},{2}>", LogHeader, x, y);
167 multiRezToBuild.Enqueue(new mapToMultiRez(x, y)); 186 multiRezToBuild.Enqueue(new mapToMultiRez(x, y, scopeID));
168 if (multiRezToBuild.Count == 1) 187 if (multiRezToBuild.Count == 1)
169 Util.FireAndForget( 188 Util.FireAndForget(
170 DoUpdateMultiResolutionFilesAsync, null, "MapImageService.DoUpdateMultiResolutionFilesAsync"); 189 DoUpdateMultiResolutionFilesAsync);
171 } 190 }
172 191
173 return true; 192 return true;
@@ -175,10 +194,8 @@ namespace OpenSim.Services.MapImageService
175 194
176 private void DoUpdateMultiResolutionFilesAsync(object o) 195 private void DoUpdateMultiResolutionFilesAsync(object o)
177 { 196 {
178 // This sleep causes the FireAndForget thread to be different than the invocation thread. 197 // let acumulate large region tiles
179 // It also allows other tiles to be uploaded so the multi-rez images are more likely 198 Thread.Sleep(60 * 1000); // large regions take time to upload tiles
180 // to be correct.
181 Thread.Sleep(1 * 1000);
182 199
183 while (multiRezToBuild.Count > 0) 200 while (multiRezToBuild.Count > 0)
184 { 201 {
@@ -192,20 +209,23 @@ namespace OpenSim.Services.MapImageService
192 { 209 {
193 int x = toMultiRez.xx; 210 int x = toMultiRez.xx;
194 int y = toMultiRez.yy; 211 int y = toMultiRez.yy;
212 UUID scopeID = toMultiRez.scopeID;
195 // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y); 213 // m_log.DebugFormat("{0} DoUpdateMultiResolutionFilesAsync: doing build for <{1},{2}>", LogHeader, x, y);
196 214
215 int width = 1;
216
197 // Stitch seven more aggregate tiles together 217 // Stitch seven more aggregate tiles together
198 for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++) 218 for (uint zoomLevel = 2; zoomLevel <= ZOOM_LEVELS; zoomLevel++)
199 { 219 {
200 // Calculate the width (in full resolution tiles) and bottom-left 220 // Calculate the width (in full resolution tiles) and bottom-left
201 // corner of the current zoom level 221 // corner of the current zoom level
202 int width = (int)Math.Pow(2, (double)(zoomLevel - 1)); 222 width *= 2;
203 int x1 = x - (x % width); 223 int x1 = x - (x % width);
204 int y1 = y - (y % width); 224 int y1 = y - (y % width);
205 225
206 lock (m_Sync) // must lock the reading and writing of the maptile files 226 lock (m_Sync) // must lock the reading and writing of the maptile files
207 { 227 {
208 if (!CreateTile(zoomLevel, x1, y1)) 228 if (!CreateTile(zoomLevel, x1, y1, scopeID))
209 { 229 {
210 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel); 230 m_log.WarnFormat("[MAP IMAGE SERVICE]: Unable to create tile for {0},{1} at zoom level {1}", x, y, zoomLevel);
211 return; 231 return;
@@ -214,25 +234,25 @@ namespace OpenSim.Services.MapImageService
214 } 234 }
215 } 235 }
216 } 236 }
217
218 return; 237 return;
219 } 238 }
220 239
221 public byte[] GetMapTile(string fileName, out string format) 240 public byte[] GetMapTile(string fileName, UUID scopeID, out string format)
222 { 241 {
223// m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName); 242// m_log.DebugFormat("[MAP IMAGE SERVICE]: Getting map tile {0}", fileName);
224 243
225 format = ".jpg"; 244 format = ".jpg";
226 string fullName = Path.Combine(m_TilesStoragePath, fileName); 245 string fullName = Path.Combine(m_TilesStoragePath, scopeID.ToString());
246 fullName = Path.Combine(fullName, fileName);
227 if (File.Exists(fullName)) 247 if (File.Exists(fullName))
228 { 248 {
229 format = Path.GetExtension(fileName).ToLower(); 249 format = Path.GetExtension(fileName).ToLower();
230 //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); 250 //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format);
231 return File.ReadAllBytes(fullName); 251 return File.ReadAllBytes(fullName);
232 } 252 }
233 else if (File.Exists(m_WaterTileFile)) 253 else if (m_WaterBytes != null)
234 { 254 {
235 return File.ReadAllBytes(m_WaterTileFile); 255 return (byte[])m_WaterBytes.Clone();
236 } 256 }
237 else 257 else
238 { 258 {
@@ -244,10 +264,12 @@ namespace OpenSim.Services.MapImageService
244 #endregion 264 #endregion
245 265
246 266
247 private string GetFileName(uint zoomLevel, int x, int y) 267 private string GetFileName(uint zoomLevel, int x, int y, UUID scopeID)
248 { 268 {
249 string extension = "jpg"; 269 string extension = "jpg";
250 return Path.Combine(m_TilesStoragePath, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension)); 270 string path = Path.Combine(m_TilesStoragePath, scopeID.ToString());
271 Directory.CreateDirectory(path);
272 return Path.Combine(path, string.Format("map-{0}-{1}-{2}-objects.{3}", zoomLevel, x, y, extension));
251 } 273 }
252 274
253 private Bitmap GetInputTileImage(string fileName) 275 private Bitmap GetInputTileImage(string fileName)
@@ -276,7 +298,7 @@ namespace OpenSim.Services.MapImageService
276 { 298 {
277 // Create a new output tile with a transparent background 299 // Create a new output tile with a transparent background
278 Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb); 300 Bitmap bm = new Bitmap(IMAGE_WIDTH, IMAGE_WIDTH, PixelFormat.Format24bppRgb);
279 bm.MakeTransparent(); 301 //bm.MakeTransparent(); // 24bpp does not have transparency, this whould make it 32bpp
280 return bm; 302 return bm;
281 } 303 }
282 } 304 }
@@ -288,7 +310,7 @@ namespace OpenSim.Services.MapImageService
288 return null; 310 return null;
289 } 311 }
290 312
291 private bool CreateTile(uint zoomLevel, int x, int y) 313 private bool CreateTile(uint zoomLevel, int x, int y, UUID scopeID)
292 { 314 {
293// m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel); 315// m_log.DebugFormat("[MAP IMAGE SERVICE]: Create tile for {0} {1}, zoom {2}", x, y, zoomLevel);
294 int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2); 316 int prevWidth = (int)Math.Pow(2, (double)zoomLevel - 2);
@@ -303,55 +325,60 @@ namespace OpenSim.Services.MapImageService
303 int yOut = y - (y % thisWidth); 325 int yOut = y - (y % thisWidth);
304 326
305 // Try to open the four input tiles from the previous zoom level 327 // Try to open the four input tiles from the previous zoom level
306 Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn)); 328 Bitmap inputBL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn, scopeID));
307 Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn)); 329 Bitmap inputBR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn, scopeID));
308 Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth)); 330 Bitmap inputTL = GetInputTileImage(GetFileName(zoomLevel - 1, xIn, yIn + prevWidth, scopeID));
309 Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth)); 331 Bitmap inputTR = GetInputTileImage(GetFileName(zoomLevel - 1, xIn + prevWidth, yIn + prevWidth, scopeID));
310 332
311 // Open the output tile (current zoom level) 333 // Open the output tile (current zoom level)
312 string outputFile = GetFileName(zoomLevel, xOut, yOut); 334 string outputFile = GetFileName(zoomLevel, xOut, yOut, scopeID);
313 Bitmap output = GetOutputTileImage(outputFile); 335
314 if (output == null) 336 int ntiles = 0;
315 return false; 337 Bitmap output = (Bitmap)m_WaterBitmap.Clone();
316 FillImage(output, m_Watercolor);
317 338
318 if (inputBL != null) 339 if (inputBL != null)
319 { 340 {
320 ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0); 341 ImageCopyResampled(output, inputBL, 0, HALF_WIDTH, 0, 0);
321 inputBL.Dispose(); 342 inputBL.Dispose();
343 ntiles++;
322 } 344 }
323 if (inputBR != null) 345 if (inputBR != null)
324 { 346 {
325 ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0); 347 ImageCopyResampled(output, inputBR, HALF_WIDTH, HALF_WIDTH, 0, 0);
326 inputBR.Dispose(); 348 inputBR.Dispose();
349 ntiles++;
327 } 350 }
328 if (inputTL != null) 351 if (inputTL != null)
329 { 352 {
330 ImageCopyResampled(output, inputTL, 0, 0, 0, 0); 353 ImageCopyResampled(output, inputTL, 0, 0, 0, 0);
331 inputTL.Dispose(); 354 inputTL.Dispose();
355 ntiles++;
332 } 356 }
333 if (inputTR != null) 357 if (inputTR != null)
334 { 358 {
335 ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0); 359 ImageCopyResampled(output, inputTR, HALF_WIDTH, 0, 0, 0);
336 inputTR.Dispose(); 360 inputTR.Dispose();
361 ntiles++;
337 } 362 }
338 363
339 // Write the modified output 364 // Write the modified output
340 try 365 if (ntiles == 0)
366 File.Delete(outputFile);
367
368 else
341 { 369 {
342 using (Bitmap final = new Bitmap(output)) 370
371 try
343 { 372 {
344 output.Dispose(); 373 output.Save(outputFile, ImageFormat.Jpeg);
345 final.Save(outputFile, ImageFormat.Jpeg);
346 } 374 }
347 } 375 catch (Exception e)
348 catch (Exception e) 376 {
349 { 377 m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e);
350 m_log.WarnFormat("[MAP IMAGE SERVICE]: Oops on saving {0} {1}", outputFile, e); 378 }
351 } 379 } // Save also as png?
352
353 // Save also as png?
354 380
381 output.Dispose();
355 return true; 382 return true;
356 } 383 }
357 384
diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs
index d9684c4..7a544fa 100644
--- a/OpenSim/Services/SimulationService/SimulationDataService.cs
+++ b/OpenSim/Services/SimulationService/SimulationDataService.cs
@@ -173,6 +173,11 @@ namespace OpenSim.Services.SimulationService
173 m_database.RemoveRegionEnvironmentSettings(regionUUID); 173 m_database.RemoveRegionEnvironmentSettings(regionUUID);
174 } 174 }
175 175
176 public UUID[] GetObjectIDs(UUID regionID)
177 {
178 return m_database.GetObjectIDs(regionID);
179 }
180
176 public void SaveExtra(UUID regionID, string name, string val) 181 public void SaveExtra(UUID regionID, string name, string val)
177 { 182 {
178 m_database.SaveExtra(regionID, name, val); 183 m_database.SaveExtra(regionID, name, val);
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 2e19ece..987a07d 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -176,6 +176,10 @@ namespace OpenSim.Services.UserAccountService
176 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); 176 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
177 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) 177 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
178 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); 178 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
179 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
180 u.UserCountry = d.Data["UserCountry"].ToString();
181 else
182 u.UserTitle = string.Empty;
179 183
180 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) 184 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
181 { 185 {
@@ -301,7 +305,22 @@ namespace OpenSim.Services.UserAccountService
301 305
302 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 306 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
303 { 307 {
304 UserAccountData[] d = m_Database.GetUsers(scopeID, query); 308 UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
309
310 if (d == null)
311 return new List<UserAccount>();
312
313 List<UserAccount> ret = new List<UserAccount>();
314
315 foreach (UserAccountData data in d)
316 ret.Add(MakeUserAccount(data));
317
318 return ret;
319 }
320
321 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
322 {
323 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
305 324
306 if (d == null) 325 if (d == null)
307 return new List<UserAccount>(); 326 return new List<UserAccount>();
diff --git a/OpenSim/Services/UserProfilesService/UserProfilesService.cs b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
index 96c13c0..9a52e02 100644
--- a/OpenSim/Services/UserProfilesService/UserProfilesService.cs
+++ b/OpenSim/Services/UserProfilesService/UserProfilesService.cs
@@ -159,6 +159,7 @@ namespace OpenSim.Services.ProfilesService
159 } 159 }
160 #endregion Interests 160 #endregion Interests
161 161
162
162 #region User Preferences 163 #region User Preferences
163 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result) 164 public bool UserPreferencesUpdate(ref UserPreferences pref, ref string result)
164 { 165 {
@@ -239,6 +240,7 @@ namespace OpenSim.Services.ProfilesService
239 } 240 }
240 #endregion User Preferences 241 #endregion User Preferences
241 242
243
242 #region Utility 244 #region Utility
243 public OSD AvatarImageAssetsRequest(UUID avatarId) 245 public OSD AvatarImageAssetsRequest(UUID avatarId)
244 { 246 {