aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs69
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs34
-rw-r--r--OpenSim/Services/HypergridService/HGFSAssetService.cs189
-rw-r--r--OpenSim/Services/HypergridService/HGFriendsService.cs3
-rw-r--r--OpenSim/Services/HypergridService/HGInstantMessageService.cs19
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs19
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs237
-rw-r--r--OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs2
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs7
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs35
10 files changed, 444 insertions, 170 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index f6136b5..44b26d5 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -204,29 +204,63 @@ namespace OpenSim.Services.HypergridService
204 return true; 204 return true;
205 } 205 }
206 206
207 public GridRegion GetHyperlinkRegion(UUID regionID) 207 public GridRegion GetHyperlinkRegion(UUID regionID, UUID agentID, string agentHomeURI, out string message)
208 { 208 {
209 m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get hyperlink region {0}", regionID); 209 message = null;
210 210
211 if (!m_AllowTeleportsToAnyRegion) 211 if (!m_AllowTeleportsToAnyRegion)
212 {
212 // Don't even check the given regionID 213 // Don't even check the given regionID
214 m_log.DebugFormat(
215 "[GATEKEEPER SERVICE]: Returning gateway region {0} {1} @ {2} to user {3}{4} as teleporting to arbitrary regions is not allowed.",
216 m_DefaultGatewayRegion.RegionName,
217 m_DefaultGatewayRegion.RegionID,
218 m_DefaultGatewayRegion.ServerURI,
219 agentID,
220 agentHomeURI == null ? "" : " @ " + agentHomeURI);
221
222 message = "Teleporting to the default region.";
213 return m_DefaultGatewayRegion; 223 return m_DefaultGatewayRegion;
224 }
214 225
215 GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID); 226 GridRegion region = m_GridService.GetRegionByUUID(m_ScopeID, regionID);
227
228 if (region == null)
229 {
230 m_log.DebugFormat(
231 "[GATEKEEPER SERVICE]: Could not find region with ID {0} as requested by user {1}{2}. Returning null.",
232 regionID, agentID, (agentHomeURI == null) ? "" : " @ " + agentHomeURI);
233
234 message = "The teleport destination could not be found.";
235 return null;
236 }
237
238 m_log.DebugFormat(
239 "[GATEKEEPER SERVICE]: Returning region {0} {1} @ {2} to user {3}{4}.",
240 region.RegionName,
241 region.RegionID,
242 region.ServerURI,
243 agentID,
244 agentHomeURI == null ? "" : " @ " + agentHomeURI);
245
216 return region; 246 return region;
217 } 247 }
218 248
219 #region Login Agent 249 #region Login Agent
220 public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) 250 public bool LoginAgent(GridRegion source, AgentCircuitData aCircuit, GridRegion destination, out string reason)
221 { 251 {
222 reason = string.Empty; 252 reason = string.Empty;
223 253
224 string authURL = string.Empty; 254 string authURL = string.Empty;
225 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 255 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
226 authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 256 authURL = aCircuit.ServiceURLs["HomeURI"].ToString();
227 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9} Teleport Flags {10}", 257
228 aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionName, 258 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2} ({3}) at {4} using viewer {5}, channel {6}, IP {7}, Mac {8}, Id0 {9}, Teleport Flags: {10}. From region {11}",
229 aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, aCircuit.teleportFlags.ToString()); 259 aCircuit.firstname, aCircuit.lastname, authURL, aCircuit.AgentID, destination.RegionID,
260 aCircuit.Viewer, aCircuit.Channel, aCircuit.IPAddress, aCircuit.Mac, aCircuit.Id0, (TeleportFlags)aCircuit.teleportFlags,
261 (source == null) ? "Unknown" : string.Format("{0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI));
262
263 string curViewer = Util.GetViewerName(aCircuit);
230 264
231 // 265 //
232 // Check client 266 // Check client
@@ -234,11 +268,11 @@ namespace OpenSim.Services.HypergridService
234 if (m_AllowedClients != string.Empty) 268 if (m_AllowedClients != string.Empty)
235 { 269 {
236 Regex arx = new Regex(m_AllowedClients); 270 Regex arx = new Regex(m_AllowedClients);
237 Match am = arx.Match(aCircuit.Viewer); 271 Match am = arx.Match(curViewer);
238 272
239 if (!am.Success) 273 if (!am.Success)
240 { 274 {
241 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", aCircuit.Viewer); 275 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is not allowed", curViewer);
242 return false; 276 return false;
243 } 277 }
244 } 278 }
@@ -246,11 +280,11 @@ namespace OpenSim.Services.HypergridService
246 if (m_DeniedClients != string.Empty) 280 if (m_DeniedClients != string.Empty)
247 { 281 {
248 Regex drx = new Regex(m_DeniedClients); 282 Regex drx = new Regex(m_DeniedClients);
249 Match dm = drx.Match(aCircuit.Viewer); 283 Match dm = drx.Match(curViewer);
250 284
251 if (dm.Success) 285 if (dm.Success)
252 { 286 {
253 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", aCircuit.Viewer); 287 m_log.InfoFormat("[GATEKEEPER SERVICE]: Login failed, reason: client {0} is denied", curViewer);
254 return false; 288 return false;
255 } 289 }
256 } 290 }
@@ -396,7 +430,7 @@ namespace OpenSim.Services.HypergridService
396 try 430 try
397 { 431 {
398 Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); 432 Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString());
399 aCircuit.lastname = "@" + uri.Host; // + ":" + uri.Port; 433 aCircuit.lastname = "@" + uri.Authority;
400 } 434 }
401 catch 435 catch
402 { 436 {
@@ -413,9 +447,16 @@ namespace OpenSim.Services.HypergridService
413 // Preserve our TeleportFlags we have gathered so-far 447 // Preserve our TeleportFlags we have gathered so-far
414 loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags; 448 loginFlag |= (Constants.TeleportFlags) aCircuit.teleportFlags;
415 449
416 m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0} {1}", aCircuit.Name, loginFlag); 450 m_log.DebugFormat("[GATEKEEPER SERVICE]: Launching {0}, Teleport Flags: {1}", aCircuit.Name, loginFlag);
451
452 string version;
453
454 if (!m_SimulationService.QueryAccess(
455 destination, aCircuit.AgentID, aCircuit.ServiceURLs["HomeURI"].ToString(),
456 true, aCircuit.startpos, "SIMULATION/0.3", new List<UUID>(), out version, out reason))
457 return false;
417 458
418 return m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, out reason); 459 return m_SimulationService.CreateAgent(source, destination, aCircuit, (uint)loginFlag, out reason);
419 } 460 }
420 461
421 protected bool Authenticate(AgentCircuitData aCircuit) 462 protected bool Authenticate(AgentCircuitData aCircuit)
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index 84dec8d..b83fb1e 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -76,10 +76,10 @@ namespace OpenSim.Services.HypergridService
76 if (m_UserAccountService == null) 76 if (m_UserAccountService == null)
77 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); 77 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
78 78
79 // legacy configuration [obsolete] 79 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
80 m_HomeURL = assetConfig.GetString("ProfileServerURI", string.Empty); 80 new string[] { "Startup", "Hypergrid", configName }, string.Empty);
81 // Preferred 81 if (m_HomeURL == string.Empty)
82 m_HomeURL = assetConfig.GetString("HomeURI", m_HomeURL); 82 throw new Exception("[HGAssetService] No HomeURI specified");
83 83
84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 84 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
85 85
@@ -100,7 +100,7 @@ namespace OpenSim.Services.HypergridService
100 return null; 100 return null;
101 101
102 if (asset.Metadata.Type == (sbyte)AssetType.Object) 102 if (asset.Metadata.Type == (sbyte)AssetType.Object)
103 asset.Data = AdjustIdentifiers(asset.Data); ; 103 asset.Data = AdjustIdentifiers(asset.Data);
104 104
105 AdjustIdentifiers(asset.Metadata); 105 AdjustIdentifiers(asset.Metadata);
106 106
@@ -129,6 +129,14 @@ namespace OpenSim.Services.HypergridService
129 if (!m_AssetPerms.AllowedExport(asset.Type)) 129 if (!m_AssetPerms.AllowedExport(asset.Type))
130 return null; 130 return null;
131 131
132 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
133 // Fix bad assets before sending them elsewhere
134 if (asset.Type == (int)AssetType.Object && asset.Data != null)
135 {
136 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
137 asset.Data = Utils.StringToBytes(xml);
138 }
139
132 return asset.Data; 140 return asset.Data;
133 } 141 }
134 142
@@ -139,6 +147,14 @@ namespace OpenSim.Services.HypergridService
139 if (!m_AssetPerms.AllowedImport(asset.Type)) 147 if (!m_AssetPerms.AllowedImport(asset.Type))
140 return string.Empty; 148 return string.Empty;
141 149
150 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
151 // Fix bad assets before storing on this server
152 if (asset.Type == (int)AssetType.Object && asset.Data != null)
153 {
154 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
155 asset.Data = Utils.StringToBytes(xml);
156 }
157
142 return base.Store(asset); 158 return base.Store(asset);
143 } 159 }
144 160
@@ -160,10 +176,16 @@ namespace OpenSim.Services.HypergridService
160 meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName; 176 meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName;
161 } 177 }
162 178
179 // Only for Object
163 protected byte[] AdjustIdentifiers(byte[] data) 180 protected byte[] AdjustIdentifiers(byte[] data)
164 { 181 {
165 string xml = Utils.BytesToString(data); 182 string xml = Utils.BytesToString(data);
166 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_HomeURL, m_Cache, UUID.Zero)); 183
184 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
185 // Fix bad assets before sending them elsewhere
186 xml = ExternalRepresentationUtils.SanitizeXml(xml);
187
188 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
167 } 189 }
168 190
169 } 191 }
diff --git a/OpenSim/Services/HypergridService/HGFSAssetService.cs b/OpenSim/Services/HypergridService/HGFSAssetService.cs
new file mode 100644
index 0000000..54e8ccb
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGFSAssetService.cs
@@ -0,0 +1,189 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Reflection;
29
30using Nini.Config;
31using log4net;
32using OpenMetaverse;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Serialization.External;
36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.FSAssetService;
39
40namespace OpenSim.Services.HypergridService
41{
42 /// <summary>
43 /// Hypergrid asset service. It serves the IAssetService interface,
44 /// but implements it in ways that are appropriate for inter-grid
45 /// asset exchanges. This version is for FSAssets.
46 /// </summary>
47 public class HGFSAssetService : FSAssetConnector, IAssetService
48 {
49 private static readonly ILog m_log =
50 LogManager.GetLogger(
51 MethodBase.GetCurrentMethod().DeclaringType);
52
53 private string m_HomeURL;
54 private IUserAccountService m_UserAccountService;
55
56 private UserAccountCache m_Cache;
57
58 private AssetPermissions m_AssetPerms;
59
60 public HGFSAssetService(IConfigSource config, string configName) : base(config, "AssetService")
61 {
62 m_log.Debug("[HGAsset Service]: Starting in FSAsset mode");
63 IConfig assetConfig = config.Configs[configName];
64 if (assetConfig == null)
65 throw new Exception("No HGAssetService configuration");
66
67 string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
68 if (userAccountsDll == string.Empty)
69 throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
70
71 Object[] args = new Object[] { config };
72 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
73 if (m_UserAccountService == null)
74 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
75
76 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
77 new string[] { "Startup", "Hypergrid", configName }, string.Empty);
78 if (m_HomeURL == string.Empty)
79 throw new Exception("[HGAssetService] No HomeURI specified");
80
81 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
82
83 // Permissions
84 m_AssetPerms = new AssetPermissions(assetConfig);
85 }
86
87 #region IAssetService overrides
88 public override AssetBase Get(string id)
89 {
90 AssetBase asset = base.Get(id);
91
92 if (asset == null)
93 return null;
94
95 if (!m_AssetPerms.AllowedExport(asset.Type))
96 return null;
97
98 if (asset.Metadata.Type == (sbyte)AssetType.Object)
99 asset.Data = AdjustIdentifiers(asset.Data);
100
101 AdjustIdentifiers(asset.Metadata);
102
103 return asset;
104 }
105
106 public override AssetMetadata GetMetadata(string id)
107 {
108 AssetMetadata meta = base.GetMetadata(id);
109
110 if (meta == null)
111 return null;
112
113 AdjustIdentifiers(meta);
114
115 return meta;
116 }
117
118 public override byte[] GetData(string id)
119 {
120 AssetBase asset = Get(id);
121
122 if (asset == null)
123 return null;
124
125 if (!m_AssetPerms.AllowedExport(asset.Type))
126 return null;
127
128 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
129 // Fix bad assets before sending them elsewhere
130 if (asset.Type == (int)AssetType.Object && asset.Data != null)
131 {
132 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
133 asset.Data = Utils.StringToBytes(xml);
134 }
135
136 return asset.Data;
137 }
138
139 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
140
141 public override string Store(AssetBase asset)
142 {
143 if (!m_AssetPerms.AllowedImport(asset.Type))
144 return string.Empty;
145
146 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
147 // Fix bad assets before storing on this server
148 if (asset.Type == (int)AssetType.Object && asset.Data != null)
149 {
150 string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
151 asset.Data = Utils.StringToBytes(xml);
152 }
153
154 return base.Store(asset);
155 }
156
157 public override bool Delete(string id)
158 {
159 // NOGO
160 return false;
161 }
162
163 #endregion
164
165 protected void AdjustIdentifiers(AssetMetadata meta)
166 {
167 if (meta == null || m_Cache == null)
168 return;
169
170 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
171 if (creator != null)
172 meta.CreatorID = meta.CreatorID + ";" + m_HomeURL + "/" + creator.FirstName + " " + creator.LastName;
173 }
174
175 // Only for Object
176 protected byte[] AdjustIdentifiers(byte[] data)
177 {
178 string xml = Utils.BytesToString(data);
179
180 // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
181 // Fix bad assets before sending them elsewhere
182 xml = ExternalRepresentationUtils.SanitizeXml(xml);
183
184 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
185 }
186
187 }
188
189}
diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs
index a8bcfb2..6e35a88 100644
--- a/OpenSim/Services/HypergridService/HGFriendsService.cs
+++ b/OpenSim/Services/HypergridService/HGFriendsService.cs
@@ -198,7 +198,8 @@ namespace OpenSim.Services.HypergridService
198 // So let's send back the call, but start a thread to continue 198 // So let's send back the call, but start a thread to continue
199 // with the verification and the actual action. 199 // with the verification and the actual action.
200 200
201 Util.FireAndForget(delegate { ProcessFriendshipOffered(fromID, fromName, toID, message); }); 201 Util.FireAndForget(
202 o => ProcessFriendshipOffered(fromID, fromName, toID, message), null, "HGFriendsService.ProcessFriendshipOffered");
202 203
203 return true; 204 return true;
204 } 205 }
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index e8d7cca..32ca09a 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -101,7 +101,14 @@ namespace OpenSim.Services.HypergridService
101 Object[] args = new Object[] { config }; 101 Object[] args = new Object[] { config };
102 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 102 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
103 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 103 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
104 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(userAgentService, args); 104 try
105 {
106 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(userAgentService, args);
107 }
108 catch
109 {
110 m_log.WarnFormat("[HG IM SERVICE]: Unable to create User Agent Service. Missing config var in [HGInstantMessageService]?");
111 }
105 112
106 m_RegionCache = new ExpiringCache<UUID, GridRegion>(); 113 m_RegionCache = new ExpiringCache<UUID, GridRegion>();
107 114
@@ -215,7 +222,15 @@ namespace OpenSim.Services.HypergridService
215 { 222 {
216 // Let's check with the UAS if the user is elsewhere 223 // Let's check with the UAS if the user is elsewhere
217 m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service"); 224 m_log.DebugFormat("[HG IM SERVICE]: User is not present. Checking location with User Agent service");
218 url = m_UserAgentService.LocateUser(toAgentID); 225 try
226 {
227 url = m_UserAgentService.LocateUser(toAgentID);
228 }
229 catch (Exception e)
230 {
231 m_log.Warn("[HG IM SERVICE]: LocateUser call failed ", e);
232 url = string.Empty;
233 }
219 } 234 }
220 235
221 // check if we've tried this before.. 236 // check if we've tried this before..
diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index 3233caf..9158b41 100644
--- a/OpenSim/Services/HypergridService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -103,12 +103,6 @@ namespace OpenSim.Services.HypergridService
103 return new List<InventoryFolderBase>(); 103 return new List<InventoryFolderBase>();
104 } 104 }
105 105
106 public override InventoryCollection GetUserInventory(UUID userID)
107 {
108 // NOGO for this inventory service
109 return null;
110 }
111
112 public override InventoryFolderBase GetRootFolder(UUID principalID) 106 public override InventoryFolderBase GetRootFolder(UUID principalID)
113 { 107 {
114 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 108 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
@@ -121,7 +115,7 @@ namespace OpenSim.Services.HypergridService
121 return ConvertToOpenSim(folders[0]); 115 return ConvertToOpenSim(folders[0]);
122 116
123 // make one 117 // make one
124 XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)AssetType.Folder, "My Suitcase"); 118 XInventoryFolder suitcase = CreateFolder(principalID, UUID.Zero, (int)FolderType.Suitcase, "My Suitcase");
125 return ConvertToOpenSim(suitcase); 119 return ConvertToOpenSim(suitcase);
126 } 120 }
127 121
@@ -147,7 +141,7 @@ namespace OpenSim.Services.HypergridService
147 //} 141 //}
148 142
149 143
150 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 144 public override InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
151 { 145 {
152 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); 146 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
153 return GetRootFolder(principalID); 147 return GetRootFolder(principalID);
@@ -159,7 +153,14 @@ namespace OpenSim.Services.HypergridService
159 //public InventoryCollection GetFolderContent(UUID principalID, UUID folderID) 153 //public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
160 //{ 154 //{
161 //} 155 //}
162 156
157 // NOGO
158 //
159 public override InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderID)
160 {
161 return new InventoryCollection[0];
162 }
163
163 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 164 //public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
164 //{ 165 //{
165 //} 166 //}
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 835cde3..40eb6d4 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Services.HypergridService
122 } 122 }
123 123
124 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); 124 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
125 if (tree == null || (tree != null && tree.Count == 0)) 125 if (tree.Count == 0)
126 return null; 126 return null;
127 127
128 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 128 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
@@ -137,59 +137,6 @@ namespace OpenSim.Services.HypergridService
137 return folders; 137 return folders;
138 } 138 }
139 139
140 public override InventoryCollection GetUserInventory(UUID userID)
141 {
142 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID);
143
144 InventoryCollection userInventory = new InventoryCollection();
145 userInventory.UserID = userID;
146 userInventory.Folders = new List<InventoryFolderBase>();
147 userInventory.Items = new List<InventoryItemBase>();
148
149 XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
150
151 if (suitcase == null)
152 {
153 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no suitcase folder for user {0} when looking for user inventory", userID);
154 return null;
155 }
156
157 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
158 if (tree == null || (tree != null && tree.Count == 0))
159 {
160 SetAsNormalFolder(suitcase);
161 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
162 return userInventory;
163 }
164
165 List<InventoryItemBase> items;
166 foreach (XInventoryFolder f in tree)
167 {
168 // Add the items of this subfolder
169 items = GetFolderItems(userID, f.folderID);
170 if (items != null && items.Count > 0)
171 {
172 userInventory.Items.AddRange(items);
173 }
174
175 // Add the folder itself
176 userInventory.Folders.Add(ConvertToOpenSim(f));
177 }
178
179 items = GetFolderItems(userID, suitcase.folderID);
180 if (items != null && items.Count > 0)
181 {
182 userInventory.Items.AddRange(items);
183 }
184
185 SetAsNormalFolder(suitcase);
186 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
187
188 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
189 userID, userInventory.Folders.Count, userInventory.Items.Count);
190 return userInventory;
191 }
192
193 public override InventoryFolderBase GetRootFolder(UUID principalID) 140 public override InventoryFolderBase GetRootFolder(UUID principalID)
194 { 141 {
195 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 142 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
@@ -209,27 +156,21 @@ namespace OpenSim.Services.HypergridService
209 if (suitcase == null) 156 if (suitcase == null)
210 { 157 {
211 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID); 158 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
212 // make one, and let's add it to the user's inventory as a direct child of the root folder 159 // Create the My Suitcase folder under the user's root folder.
213 // In the DB we tag it as type 100, but we use -1 (Unknown) outside 160 // In the DB we tag it as type 100, but we use type 8 (Folder) outside, as this affects the sort order.
214 suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase"); 161 suitcase = CreateFolder(principalID, root.folderID, (int)FolderType.Suitcase, InventoryFolderBase.SUITCASE_FOLDER_NAME);
215 if (suitcase == null) 162 if (suitcase == null)
216 { 163 {
217 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder"); 164 m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
165 return null;
218 } 166 }
219 else
220 {
221 m_Database.StoreFolder(suitcase);
222
223 // Create System folders
224 CreateSystemFolders(principalID, suitcase.folderID);
225 167
226 SetAsNormalFolder(suitcase); 168 CreateSystemFolders(principalID, suitcase.folderID);
227
228 return ConvertToOpenSim(suitcase);
229 }
230 } 169 }
231 170
232 return null; 171 SetAsNormalFolder(suitcase);
172
173 return ConvertToOpenSim(suitcase);
233 } 174 }
234 175
235 protected void CreateSystemFolders(UUID principalID, UUID rootID) 176 protected void CreateSystemFolders(UUID principalID, UUID rootID)
@@ -237,42 +178,41 @@ namespace OpenSim.Services.HypergridService
237 m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase..."); 178 m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase...");
238 XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID); 179 XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID);
239 180
240 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; })) 181 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Animation) return true; return false; }))
241 CreateFolder(principalID, rootID, (int)AssetType.Animation, "Animations"); 182 CreateFolder(principalID, rootID, (int)FolderType.Animation, "Animations");
242 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; })) 183 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.BodyPart) return true; return false; }))
243 CreateFolder(principalID, rootID, (int)AssetType.Bodypart, "Body Parts"); 184 CreateFolder(principalID, rootID, (int)FolderType.BodyPart, "Body Parts");
244 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; })) 185 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CallingCard) return true; return false; }))
245 CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards"); 186 CreateFolder(principalID, rootID, (int)FolderType.CallingCard, "Calling Cards");
246 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; })) 187 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Clothing) return true; return false; }))
247 CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing"); 188 CreateFolder(principalID, rootID, (int)FolderType.Clothing, "Clothing");
248 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; })) 189 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.CurrentOutfit) return true; return false; }))
249 CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures"); 190 CreateFolder(principalID, rootID, (int)FolderType.CurrentOutfit, "Current Outfit");
250 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; })) 191 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Favorites) return true; return false; }))
251 CreateFolder(principalID, rootID, (int)AssetType.Landmark, "Landmarks"); 192 CreateFolder(principalID, rootID, (int)FolderType.Favorites, "Favorites");
252 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; })) 193 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Gesture) return true; return false; }))
253 CreateFolder(principalID, rootID, (int)AssetType.LostAndFoundFolder, "Lost And Found"); 194 CreateFolder(principalID, rootID, (int)FolderType.Gesture, "Gestures");
254 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; })) 195 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Landmark) return true; return false; }))
255 CreateFolder(principalID, rootID, (int)AssetType.Notecard, "Notecards"); 196 CreateFolder(principalID, rootID, (int)FolderType.Landmark, "Landmarks");
256 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; })) 197 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LostAndFound) return true; return false; }))
257 CreateFolder(principalID, rootID, (int)AssetType.Object, "Objects"); 198 CreateFolder(principalID, rootID, (int)FolderType.LostAndFound, "Lost And Found");
258 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; })) 199 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Notecard) return true; return false; }))
259 CreateFolder(principalID, rootID, (int)AssetType.SnapshotFolder, "Photo Album"); 200 CreateFolder(principalID, rootID, (int)FolderType.Notecard, "Notecards");
260 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; })) 201 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Object) return true; return false; }))
261 CreateFolder(principalID, rootID, (int)AssetType.LSLText, "Scripts"); 202 CreateFolder(principalID, rootID, (int)FolderType.Object, "Objects");
262 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; })) 203 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Snapshot) return true; return false; }))
263 CreateFolder(principalID, rootID, (int)AssetType.Sound, "Sounds"); 204 CreateFolder(principalID, rootID, (int)FolderType.Snapshot, "Photo Album");
264 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; })) 205 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.LSLText) return true; return false; }))
265 CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures"); 206 CreateFolder(principalID, rootID, (int)FolderType.LSLText, "Scripts");
266 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; })) 207 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Sound) return true; return false; }))
267 CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash"); 208 CreateFolder(principalID, rootID, (int)FolderType.Sound, "Sounds");
268 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; })) 209 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Texture) return true; return false; }))
269 CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites"); 210 CreateFolder(principalID, rootID, (int)FolderType.Texture, "Textures");
270 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; })) 211 if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)FolderType.Trash) return true; return false; }))
271 CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit"); 212 CreateFolder(principalID, rootID, (int)FolderType.Trash, "Trash");
272
273 } 213 }
274 214
275 public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 215 public override InventoryFolderBase GetFolderForType(UUID principalID, FolderType type)
276 { 216 {
277 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type); 217 //m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
278 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 218 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
@@ -305,7 +245,10 @@ namespace OpenSim.Services.HypergridService
305 InventoryCollection coll = null; 245 InventoryCollection coll = null;
306 246
307 if (!IsWithinSuitcaseTree(principalID, folderID)) 247 if (!IsWithinSuitcaseTree(principalID, folderID))
248 {
249 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID);
308 return new InventoryCollection(); 250 return new InventoryCollection();
251 }
309 252
310 coll = base.GetFolderContent(principalID, folderID); 253 coll = base.GetFolderContent(principalID, folderID);
311 254
@@ -322,7 +265,10 @@ namespace OpenSim.Services.HypergridService
322 // Let's do a bit of sanity checking, more than the base service does 265 // Let's do a bit of sanity checking, more than the base service does
323 // make sure the given folder exists under the suitcase tree of this user 266 // make sure the given folder exists under the suitcase tree of this user
324 if (!IsWithinSuitcaseTree(principalID, folderID)) 267 if (!IsWithinSuitcaseTree(principalID, folderID))
268 {
269 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderItems: folder {0} (user {1}) is not within Suitcase tree", folderID, principalID);
325 return new List<InventoryItemBase>(); 270 return new List<InventoryItemBase>();
271 }
326 272
327 return base.GetFolderItems(principalID, folderID); 273 return base.GetFolderItems(principalID, folderID);
328 } 274 }
@@ -334,7 +280,10 @@ namespace OpenSim.Services.HypergridService
334 // make sure the given folder's parent folder exists under the suitcase tree of this user 280 // make sure the given folder's parent folder exists under the suitcase tree of this user
335 281
336 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 282 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
283 {
284 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
337 return false; 285 return false;
286 }
338 287
339 // OK, it's legit 288 // OK, it's legit
340 if (base.AddFolder(folder)) 289 if (base.AddFolder(folder))
@@ -354,7 +303,7 @@ namespace OpenSim.Services.HypergridService
354 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 303 //m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
355 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) 304 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
356 { 305 {
357 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 306 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateFolder: folder {0}/{1} (user {2}) is not within Suitcase tree", folder.Name, folder.ID, folder.Owner);
358 return false; 307 return false;
359 } 308 }
360 309
@@ -364,9 +313,17 @@ namespace OpenSim.Services.HypergridService
364 313
365 public override bool MoveFolder(InventoryFolderBase folder) 314 public override bool MoveFolder(InventoryFolderBase folder)
366 { 315 {
367 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) || 316 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
368 !IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) 317 {
318 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ID, folder.Owner);
369 return false; 319 return false;
320 }
321
322 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
323 {
324 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder: folder {0} (user {1}) is not within Suitcase tree", folder.ParentID, folder.Owner);
325 return false;
326 }
370 327
371 return base.MoveFolder(folder); 328 return base.MoveFolder(folder);
372 } 329 }
@@ -388,7 +345,10 @@ namespace OpenSim.Services.HypergridService
388 // Let's do a bit of sanity checking, more than the base service does 345 // Let's do a bit of sanity checking, more than the base service does
389 // make sure the given folder's parent folder exists under the suitcase tree of this user 346 // make sure the given folder's parent folder exists under the suitcase tree of this user
390 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 347 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
348 {
349 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
391 return false; 350 return false;
351 }
392 352
393 // OK, it's legit 353 // OK, it's legit
394 return base.AddItem(item); 354 return base.AddItem(item);
@@ -398,7 +358,10 @@ namespace OpenSim.Services.HypergridService
398 public override bool UpdateItem(InventoryItemBase item) 358 public override bool UpdateItem(InventoryItemBase item)
399 { 359 {
400 if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) 360 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
361 {
362 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: UpdateItem: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
401 return false; 363 return false;
364 }
402 365
403 return base.UpdateItem(item); 366 return base.UpdateItem(item);
404 } 367 }
@@ -407,11 +370,28 @@ namespace OpenSim.Services.HypergridService
407 { 370 {
408 // Principal is b0rked. *sigh* 371 // Principal is b0rked. *sigh*
409 372
410 if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder)) 373 // Check the items' destination folders
411 return false; 374 foreach (InventoryItemBase item in items)
375 {
376 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
377 {
378 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
379 return false;
380 }
381 }
412 382
413 return base.MoveItems(principalID, items); 383 // Check the items' current folders
384 foreach (InventoryItemBase item in items)
385 {
386 InventoryItemBase originalItem = base.GetItem(item);
387 if (!IsWithinSuitcaseTree(originalItem.Owner, originalItem.Folder))
388 {
389 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItems: folder {0} (user {1}) is not within Suitcase tree", item.Folder, item.Owner);
390 return false;
391 }
392 }
414 393
394 return base.MoveItems(principalID, items);
415 } 395 }
416 396
417 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs) 397 public override bool DeleteItems(UUID principalID, List<UUID> itemIDs)
@@ -431,8 +411,8 @@ namespace OpenSim.Services.HypergridService
431 411
432 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID)) 412 if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
433 { 413 {
434 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 414 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetItem: item {0}/{1} (folder {2}) (user {3}) is not within Suitcase tree or Appearance",
435 it.Name, it.Folder); 415 it.Name, it.ID, it.Folder, it.Owner);
436 return null; 416 return null;
437 } 417 }
438 418
@@ -453,7 +433,11 @@ namespace OpenSim.Services.HypergridService
453 if (f != null) 433 if (f != null)
454 { 434 {
455 if (!IsWithinSuitcaseTree(f.Owner, f.ID)) 435 if (!IsWithinSuitcaseTree(f.Owner, f.ID))
436 {
437 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolder: folder {0}/{1} (user {2}) is not within Suitcase tree",
438 f.Name, f.ID, f.Owner);
456 return null; 439 return null;
440 }
457 } 441 }
458 442
459 return f; 443 return f;
@@ -484,7 +468,7 @@ namespace OpenSim.Services.HypergridService
484 { 468 {
485 XInventoryFolder[] folders = m_Database.GetFolders( 469 XInventoryFolder[] folders = m_Database.GetFolders(
486 new string[] { "agentID", "folderName", "type" }, 470 new string[] { "agentID", "folderName", "type" },
487 new string[] { principalID.ToString(), "My Inventory", ((int)AssetType.RootFolder).ToString() }); 471 new string[] { principalID.ToString(), InventoryFolderBase.ROOT_FOLDER_NAME, ((int)FolderType.Root).ToString() });
488 472
489 if (folders != null && folders.Length > 0) 473 if (folders != null && folders.Length > 0)
490 return folders[0]; 474 return folders[0];
@@ -492,7 +476,7 @@ namespace OpenSim.Services.HypergridService
492 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero. 476 // OK, so the RootFolder type didn't work. Let's look for any type with parent UUID.Zero.
493 folders = m_Database.GetFolders( 477 folders = m_Database.GetFolders(
494 new string[] { "agentID", "folderName", "parentFolderID" }, 478 new string[] { "agentID", "folderName", "parentFolderID" },
495 new string[] { principalID.ToString(), "My Inventory", UUID.Zero.ToString() }); 479 new string[] { principalID.ToString(), InventoryFolderBase.ROOT_FOLDER_NAME, UUID.Zero.ToString() });
496 480
497 if (folders != null && folders.Length > 0) 481 if (folders != null && folders.Length > 0)
498 return folders[0]; 482 return folders[0];
@@ -508,7 +492,7 @@ namespace OpenSim.Services.HypergridService
508 492
509 XInventoryFolder[] folders = m_Database.GetFolders( 493 XInventoryFolder[] folders = m_Database.GetFolders(
510 new string[] { "agentID", "type", "parentFolderID" }, 494 new string[] { "agentID", "type", "parentFolderID" },
511 new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString(), root.folderID.ToString() }); 495 new string[] { userID.ToString(), ((int)FolderType.CurrentOutfit).ToString(), root.folderID.ToString() });
512 496
513 if (folders.Length == 0) 497 if (folders.Length == 0)
514 return null; 498 return null;
@@ -521,7 +505,7 @@ namespace OpenSim.Services.HypergridService
521 // Warp! Root folder for travelers 505 // Warp! Root folder for travelers
522 XInventoryFolder[] folders = m_Database.GetFolders( 506 XInventoryFolder[] folders = m_Database.GetFolders(
523 new string[] { "agentID", "type" }, 507 new string[] { "agentID", "type" },
524 new string[] { principalID.ToString(), "100" }); // This is a special folder type... 508 new string[] { principalID.ToString(), ((int)FolderType.Suitcase).ToString() });
525 509
526 if (folders != null && folders.Length > 0) 510 if (folders != null && folders.Length > 0)
527 return folders[0]; 511 return folders[0];
@@ -529,13 +513,13 @@ namespace OpenSim.Services.HypergridService
529 // check to see if we have the old Suitcase folder 513 // check to see if we have the old Suitcase folder
530 folders = m_Database.GetFolders( 514 folders = m_Database.GetFolders(
531 new string[] { "agentID", "folderName", "parentFolderID" }, 515 new string[] { "agentID", "folderName", "parentFolderID" },
532 new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() }); 516 new string[] { principalID.ToString(), InventoryFolderBase.SUITCASE_FOLDER_NAME, UUID.Zero.ToString() });
533 if (folders != null && folders.Length > 0) 517 if (folders != null && folders.Length > 0)
534 { 518 {
535 // Move it to under the root folder 519 // Move it to under the root folder
536 XInventoryFolder root = GetRootXFolder(principalID); 520 XInventoryFolder root = GetRootXFolder(principalID);
537 folders[0].parentFolderID = root.folderID; 521 folders[0].parentFolderID = root.folderID;
538 folders[0].type = 100; 522 folders[0].type = (int)FolderType.Suitcase;
539 m_Database.StoreFolder(folders[0]); 523 m_Database.StoreFolder(folders[0]);
540 return folders[0]; 524 return folders[0];
541 } 525 }
@@ -545,18 +529,18 @@ namespace OpenSim.Services.HypergridService
545 529
546 private void SetAsNormalFolder(XInventoryFolder suitcase) 530 private void SetAsNormalFolder(XInventoryFolder suitcase)
547 { 531 {
548 suitcase.type = (short)AssetType.Folder; 532 //suitcase.type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
549 } 533 }
550 534
551 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder) 535 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)
552 { 536 {
553 List<XInventoryFolder> t = null; 537 List<XInventoryFolder> t;
554 if (m_SuitcaseTrees.TryGetValue(principalID, out t)) 538 if (m_SuitcaseTrees.TryGetValue(principalID, out t))
555 return t; 539 return t;
556 540
557 // Get the tree of the suitcase folder 541 // Get the tree of the suitcase folder
558 t = GetFolderTreeRecursive(folder); 542 t = GetFolderTreeRecursive(folder);
559 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes 543 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5 minutes
560 return t; 544 return t;
561 } 545 }
562 546
@@ -567,8 +551,10 @@ namespace OpenSim.Services.HypergridService
567 new string[] { "parentFolderID" }, 551 new string[] { "parentFolderID" },
568 new string[] { root.ToString() }); 552 new string[] { root.ToString() });
569 553
570 if (folders == null || (folders != null && folders.Length == 0)) 554 if (folders == null || folders.Length == 0)
555 {
571 return tree; // empty tree 556 return tree; // empty tree
557 }
572 else 558 else
573 { 559 {
574 foreach (XInventoryFolder f in folders) 560 foreach (XInventoryFolder f in folders)
@@ -601,17 +587,18 @@ namespace OpenSim.Services.HypergridService
601 List<XInventoryFolder> tree = new List<XInventoryFolder>(); 587 List<XInventoryFolder> tree = new List<XInventoryFolder>();
602 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder 588 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
603 tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); 589 tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
590
604 // Also add the Current Outfit folder to the list of available folders 591 // Also add the Current Outfit folder to the list of available folders
605 tree.Add(GetCurrentOutfitXFolder(principalID)); 592 XInventoryFolder folder = GetCurrentOutfitXFolder(principalID);
593 if (folder != null)
594 tree.Add(folder);
606 595
607 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) 596 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
608 { 597 {
609 if (fl.folderID == folderID) return true; 598 return (fl.folderID == folderID);
610 else return false;
611 }); 599 });
612 600
613 if (f == null) return false; 601 return (f != null);
614 else return true;
615 } 602 }
616 #endregion 603 #endregion
617 604
diff --git a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
index 0fb60f6..a565729 100644
--- a/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
+++ b/OpenSim/Services/HypergridService/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
29// Build Number 29// Build Number
30// Revision 30// Revision
31// 31//
32[assembly: AssemblyVersion("0.8.0.*")] 32[assembly: AssemblyVersion("0.8.2.*")]
33 33
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
index e0a3e61..6c3c655 100644
--- a/OpenSim/Services/HypergridService/UserAccountCache.cs
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -1,4 +1,4 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Reflection; 3using System.Reflection;
4 4
@@ -100,6 +100,11 @@ namespace OpenSim.Services.HypergridService
100 return null; 100 return null;
101 } 101 }
102 102
103 public void InvalidateCache(UUID userID)
104 {
105 m_UUIDCache.Remove(userID);
106 }
107
103 public bool StoreUserAccount(UserAccount data) 108 public bool StoreUserAccount(UserAccount data)
104 { 109 {
105 return false; 110 return false;
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index b414aca..c65122a 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Services.HypergridService
75 protected static string m_GridName; 75 protected static string m_GridName;
76 76
77 protected static int m_LevelOutsideContacts; 77 protected static int m_LevelOutsideContacts;
78 protected static bool m_ShowDetails;
78 79
79 protected static bool m_BypassClientVerification; 80 protected static bool m_BypassClientVerification;
80 81
@@ -128,6 +129,7 @@ namespace OpenSim.Services.HypergridService
128 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args); 129 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountService, args);
129 130
130 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0); 131 m_LevelOutsideContacts = serverConfig.GetInt("LevelOutsideContacts", 0);
132 m_ShowDetails = serverConfig.GetBoolean("ShowUserDetailsInHGProfile", true);
131 133
132 LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed"); 134 LoadTripPermissionsFromConfig(serverConfig, "ForeignTripsAllowed");
133 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions); 135 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_TripsAllowedExceptions);
@@ -215,7 +217,7 @@ namespace OpenSim.Services.HypergridService
215 return home; 217 return home;
216 } 218 }
217 219
218 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason) 220 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, bool fromLogin, out string reason)
219 { 221 {
220 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}", 222 m_log.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} {1} (@{2}) to grid {3}",
221 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI); 223 agentCircuit.firstname, agentCircuit.lastname, (fromLogin ? agentCircuit.IPAddress : "stored IP"), gatekeeper.ServerURI);
@@ -274,13 +276,12 @@ namespace OpenSim.Services.HypergridService
274 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID); 276 m_log.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}, desired region: {2}", m_GridName, gridName, region.RegionID);
275 277
276 if (m_GridName == gridName) 278 if (m_GridName == gridName)
277 success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason); 279 {
280 success = m_GatekeeperService.LoginAgent(source, agentCircuit, finalDestination, out reason);
281 }
278 else 282 else
279 { 283 {
280 success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason); 284 success = m_GatekeeperConnector.CreateAgent(source, region, agentCircuit, (uint)Constants.TeleportFlags.ViaLogin, out myExternalIP, out reason);
281 if (success)
282 // Report them as nowhere
283 m_PresenceService.ReportAgent(agentCircuit.SessionID, UUID.Zero);
284 } 285 }
285 286
286 if (!success) 287 if (!success)
@@ -307,10 +308,10 @@ namespace OpenSim.Services.HypergridService
307 return true; 308 return true;
308 } 309 }
309 310
310 public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason) 311 public bool LoginAgentToGrid(GridRegion source, AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, out string reason)
311 { 312 {
312 reason = string.Empty; 313 reason = string.Empty;
313 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason); 314 return LoginAgentToGrid(source, agentCircuit, gatekeeper, finalDestination, false, out reason);
314 } 315 }
315 316
316 TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing) 317 TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing)
@@ -572,10 +573,22 @@ namespace OpenSim.Services.HypergridService
572 573
573 if (account != null) 574 if (account != null)
574 { 575 {
575 info.Add("user_flags", (object)account.UserFlags); 576 info.Add("user_firstname", account.FirstName);
576 info.Add("user_created", (object)account.Created); 577 info.Add("user_lastname", account.LastName);
577 info.Add("user_title", (object)account.UserTitle);
578 info.Add("result", "success"); 578 info.Add("result", "success");
579
580 if (m_ShowDetails)
581 {
582 info.Add("user_flags", account.UserFlags);
583 info.Add("user_created", account.Created);
584 info.Add("user_title", account.UserTitle);
585 }
586 else
587 {
588 info.Add("user_flags", 0);
589 info.Add("user_created", 0);
590 info.Add("user_title", string.Empty);
591 }
579 } 592 }
580 593
581 return info; 594 return info;