diff options
6 files changed, 442 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs new file mode 100644 index 0000000..fb353c2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -0,0 +1,324 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Statistics; | ||
35 | |||
36 | using OpenSim.Services.Connectors; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | using OpenMetaverse; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
43 | { | ||
44 | public class RemoteXInventoryServicesConnector : BaseInventoryConnector, ISharedRegionModule, IInventoryService | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private bool m_Enabled = false; | ||
50 | private bool m_Initialized = false; | ||
51 | private Scene m_Scene; | ||
52 | private XInventoryServicesConnector m_RemoteConnector; | ||
53 | |||
54 | public Type ReplaceableInterface | ||
55 | { | ||
56 | get { return null; } | ||
57 | } | ||
58 | |||
59 | public string Name | ||
60 | { | ||
61 | get { return "RemoteXInventoryServicesConnector"; } | ||
62 | } | ||
63 | |||
64 | public RemoteXInventoryServicesConnector() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | public RemoteXInventoryServicesConnector(IConfigSource source) | ||
69 | { | ||
70 | Init(source); | ||
71 | } | ||
72 | |||
73 | protected override void Init(IConfigSource source) | ||
74 | { | ||
75 | m_RemoteConnector = new XInventoryServicesConnector(source); | ||
76 | base.Init(source); | ||
77 | } | ||
78 | |||
79 | |||
80 | #region ISharedRegionModule | ||
81 | |||
82 | public void Initialise(IConfigSource source) | ||
83 | { | ||
84 | IConfig moduleConfig = source.Configs["Modules"]; | ||
85 | if (moduleConfig != null) | ||
86 | { | ||
87 | string name = moduleConfig.GetString("InventoryServices", ""); | ||
88 | if (name == Name) | ||
89 | { | ||
90 | Init(source); | ||
91 | m_Enabled = true; | ||
92 | |||
93 | m_log.Info("[XINVENTORY CONNECTOR]: Remote XInventory enabled"); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void PostInitialise() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public void Close() | ||
103 | { | ||
104 | } | ||
105 | |||
106 | public void AddRegion(Scene scene) | ||
107 | { | ||
108 | m_Scene = scene; | ||
109 | //m_log.Debug("[XXXX] Adding scene " + m_Scene.RegionInfo.RegionName); | ||
110 | |||
111 | if (!m_Enabled) | ||
112 | return; | ||
113 | |||
114 | if (!m_Initialized) | ||
115 | { | ||
116 | m_Initialized = true; | ||
117 | } | ||
118 | |||
119 | scene.RegisterModuleInterface<IInventoryService>(this); | ||
120 | m_cache.AddRegion(scene); | ||
121 | } | ||
122 | |||
123 | public void RemoveRegion(Scene scene) | ||
124 | { | ||
125 | if (!m_Enabled) | ||
126 | return; | ||
127 | |||
128 | m_cache.RemoveRegion(scene); | ||
129 | } | ||
130 | |||
131 | public void RegionLoaded(Scene scene) | ||
132 | { | ||
133 | if (!m_Enabled) | ||
134 | return; | ||
135 | |||
136 | m_log.InfoFormat("[XINVENTORY CONNECTOR]: Enabled remote XInventory for region {0}", scene.RegionInfo.RegionName); | ||
137 | |||
138 | } | ||
139 | |||
140 | #endregion ISharedRegionModule | ||
141 | |||
142 | #region IInventoryService | ||
143 | |||
144 | public override bool CreateUserInventory(UUID user) | ||
145 | { | ||
146 | return false; | ||
147 | } | ||
148 | |||
149 | public override List<InventoryFolderBase> GetInventorySkeleton(UUID userId) | ||
150 | { | ||
151 | return new List<InventoryFolderBase>(); | ||
152 | } | ||
153 | |||
154 | public override InventoryCollection GetUserInventory(UUID userID) | ||
155 | { | ||
156 | return null; | ||
157 | } | ||
158 | |||
159 | public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
160 | { | ||
161 | try | ||
162 | { | ||
163 | m_RemoteConnector.GetUserInventory(userID, callback); | ||
164 | } | ||
165 | catch (Exception e) | ||
166 | { | ||
167 | if (StatsManager.SimExtraStats != null) | ||
168 | StatsManager.SimExtraStats.AddInventoryServiceRetrievalFailure(); | ||
169 | |||
170 | m_log.ErrorFormat("[XINVENTORY CONNECTOR]: Request inventory operation failed, {0} {1}", | ||
171 | e.Source, e.Message); | ||
172 | } | ||
173 | |||
174 | } | ||
175 | |||
176 | // inherited. See base class | ||
177 | // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
178 | |||
179 | public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) | ||
180 | { | ||
181 | return m_RemoteConnector.GetSystemFolders(userID); | ||
182 | } | ||
183 | |||
184 | public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) | ||
185 | { | ||
186 | try | ||
187 | { | ||
188 | return m_RemoteConnector.GetFolderContent(userID, folderID); | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.ErrorFormat("[XINVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}", | ||
193 | e.Source, e.Message); | ||
194 | } | ||
195 | InventoryCollection nullCollection = new InventoryCollection(); | ||
196 | nullCollection.Folders = new List<InventoryFolderBase>(); | ||
197 | nullCollection.Items = new List<InventoryItemBase>(); | ||
198 | nullCollection.UserID = userID; | ||
199 | return nullCollection; | ||
200 | } | ||
201 | |||
202 | public override List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | ||
203 | { | ||
204 | return m_RemoteConnector.GetFolderItems(userID, folderID); | ||
205 | } | ||
206 | |||
207 | public override bool AddFolder(InventoryFolderBase folder) | ||
208 | { | ||
209 | if (folder == null) | ||
210 | return false; | ||
211 | |||
212 | return m_RemoteConnector.AddFolder(folder); | ||
213 | } | ||
214 | |||
215 | public override bool UpdateFolder(InventoryFolderBase folder) | ||
216 | { | ||
217 | if (folder == null) | ||
218 | return false; | ||
219 | |||
220 | return m_RemoteConnector.UpdateFolder(folder); | ||
221 | } | ||
222 | |||
223 | public override bool MoveFolder(InventoryFolderBase folder) | ||
224 | { | ||
225 | if (folder == null) | ||
226 | return false; | ||
227 | |||
228 | return m_RemoteConnector.MoveFolder(folder); | ||
229 | } | ||
230 | |||
231 | public override bool DeleteFolders(UUID ownerID, List<UUID> folderIDs) | ||
232 | { | ||
233 | if (folderIDs == null) | ||
234 | return false; | ||
235 | if (folderIDs.Count == 0) | ||
236 | return false; | ||
237 | |||
238 | return m_RemoteConnector.DeleteFolders(ownerID, folderIDs); | ||
239 | } | ||
240 | |||
241 | |||
242 | public override bool PurgeFolder(InventoryFolderBase folder) | ||
243 | { | ||
244 | if (folder == null) | ||
245 | return false; | ||
246 | |||
247 | return m_RemoteConnector.PurgeFolder(folder); | ||
248 | } | ||
249 | |||
250 | // public bool AddItem(InventoryItemBase item) inherited | ||
251 | // Uses AddItemPlain | ||
252 | |||
253 | protected override bool AddItemPlain(InventoryItemBase item) | ||
254 | { | ||
255 | if (item == null) | ||
256 | return false; | ||
257 | |||
258 | return m_RemoteConnector.AddItem(item); | ||
259 | } | ||
260 | |||
261 | public override bool UpdateItem(InventoryItemBase item) | ||
262 | { | ||
263 | if (item == null) | ||
264 | return false; | ||
265 | |||
266 | return m_RemoteConnector.UpdateItem(item); | ||
267 | } | ||
268 | |||
269 | public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items) | ||
270 | { | ||
271 | if (items == null) | ||
272 | return false; | ||
273 | |||
274 | return m_RemoteConnector.MoveItems(ownerID, items); | ||
275 | } | ||
276 | |||
277 | |||
278 | public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs) | ||
279 | { | ||
280 | if (itemIDs == null) | ||
281 | return false; | ||
282 | if (itemIDs.Count == 0) | ||
283 | return true; | ||
284 | |||
285 | return m_RemoteConnector.DeleteItems(ownerID, itemIDs); | ||
286 | } | ||
287 | |||
288 | public override InventoryItemBase GetItem(InventoryItemBase item) | ||
289 | { | ||
290 | if (item == null) | ||
291 | return null; | ||
292 | |||
293 | return m_RemoteConnector.GetItem(item); | ||
294 | } | ||
295 | |||
296 | public override InventoryFolderBase GetFolder(InventoryFolderBase folder) | ||
297 | { | ||
298 | if (folder == null) | ||
299 | return null; | ||
300 | |||
301 | return m_RemoteConnector.GetFolder(folder); | ||
302 | } | ||
303 | |||
304 | public override bool HasInventoryForUser(UUID userID) | ||
305 | { | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | public override List<InventoryItemBase> GetActiveGestures(UUID userId) | ||
310 | { | ||
311 | return new List<InventoryItemBase>(); | ||
312 | } | ||
313 | |||
314 | public override int GetAssetPermissions(UUID userID, UUID assetID) | ||
315 | { | ||
316 | return m_RemoteConnector.GetAssetPermissions(userID, assetID); | ||
317 | } | ||
318 | |||
319 | |||
320 | #endregion | ||
321 | |||
322 | |||
323 | } | ||
324 | } | ||
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 34f7dcc..7164520 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -144,6 +144,8 @@ namespace OpenSim.Server.Handlers.Asset | |||
144 | return HandleGetActiveGestures(request); | 144 | return HandleGetActiveGestures(request); |
145 | case "GETASSETPERMISSIONS": | 145 | case "GETASSETPERMISSIONS": |
146 | return HandleGetAssetPermissions(request); | 146 | return HandleGetAssetPermissions(request); |
147 | case "GETSYSTEMFOLDERS": | ||
148 | return HandleGetSystemFolders(request); | ||
147 | } | 149 | } |
148 | m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); | 150 | m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); |
149 | } | 151 | } |
@@ -197,7 +199,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
197 | 199 | ||
198 | return ms.ToArray(); | 200 | return ms.ToArray(); |
199 | } | 201 | } |
200 | 202 | ||
201 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) | 203 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) |
202 | { | 204 | { |
203 | Dictionary<string,object> result = new Dictionary<string,object>(); | 205 | Dictionary<string,object> result = new Dictionary<string,object>(); |
@@ -540,6 +542,24 @@ namespace OpenSim.Server.Handlers.Asset | |||
540 | return encoding.GetBytes(xmlString); | 542 | return encoding.GetBytes(xmlString); |
541 | } | 543 | } |
542 | 544 | ||
545 | byte[] HandleGetSystemFolders(Dictionary<string, object> request) | ||
546 | { | ||
547 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
548 | UUID principal = UUID.Zero; | ||
549 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
550 | |||
551 | Dictionary<AssetType, InventoryFolderBase> sfolders = GetSystemFolders(principal); | ||
552 | |||
553 | if (sfolders != null) | ||
554 | foreach (KeyValuePair<AssetType, InventoryFolderBase> kvp in sfolders) | ||
555 | result[kvp.Key.ToString()] = EncodeFolder(kvp.Value); | ||
556 | |||
557 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
558 | m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
559 | UTF8Encoding encoding = new UTF8Encoding(); | ||
560 | return encoding.GetBytes(xmlString); | ||
561 | } | ||
562 | |||
543 | private Dictionary<string, object> EncodeFolder(InventoryFolderBase f) | 563 | private Dictionary<string, object> EncodeFolder(InventoryFolderBase f) |
544 | { | 564 | { |
545 | Dictionary<string, object> ret = new Dictionary<string, object>(); | 565 | Dictionary<string, object> ret = new Dictionary<string, object>(); |
@@ -623,5 +643,31 @@ namespace OpenSim.Server.Handlers.Asset | |||
623 | 643 | ||
624 | return item; | 644 | return item; |
625 | } | 645 | } |
646 | |||
647 | #region Extra | ||
648 | private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) | ||
649 | { | ||
650 | InventoryFolderBase root = m_InventoryService.GetRootFolder(userID); | ||
651 | if (root != null) | ||
652 | { | ||
653 | InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID); | ||
654 | if (content != null) | ||
655 | { | ||
656 | Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>(); | ||
657 | foreach (InventoryFolderBase folder in content.Folders) | ||
658 | { | ||
659 | if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) | ||
660 | folders[(AssetType)folder.Type] = folder; | ||
661 | } | ||
662 | // Put the root folder there, as type Folder | ||
663 | folders[AssetType.Folder] = root; | ||
664 | return folders; | ||
665 | } | ||
666 | } | ||
667 | m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID); | ||
668 | return new Dictionary<AssetType, InventoryFolderBase>(); | ||
669 | } | ||
670 | #endregion | ||
671 | |||
626 | } | 672 | } |
627 | } | 673 | } |
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs index aaa958b..daf2704 100644 --- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs +++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs | |||
@@ -72,6 +72,9 @@ namespace OpenSim.Server.Handlers.Login | |||
72 | string last = requestData["last"].ToString(); | 72 | string last = requestData["last"].ToString(); |
73 | string passwd = requestData["passwd"].ToString(); | 73 | string passwd = requestData["passwd"].ToString(); |
74 | string startLocation = string.Empty; | 74 | string startLocation = string.Empty; |
75 | UUID scopeID = UUID.Zero; | ||
76 | if (requestData["scope_id"] != null) | ||
77 | scopeID = new UUID(requestData["scope_id"].ToString()); | ||
75 | if (requestData.ContainsKey("start")) | 78 | if (requestData.ContainsKey("start")) |
76 | startLocation = requestData["start"].ToString(); | 79 | startLocation = requestData["start"].ToString(); |
77 | 80 | ||
@@ -83,7 +86,7 @@ namespace OpenSim.Server.Handlers.Login | |||
83 | m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); | 86 | m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); |
84 | 87 | ||
85 | LoginResponse reply = null; | 88 | LoginResponse reply = null; |
86 | reply = m_LocalService.Login(first, last, passwd, startLocation, remoteClient); | 89 | reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, remoteClient); |
87 | 90 | ||
88 | XmlRpcResponse response = new XmlRpcResponse(); | 91 | XmlRpcResponse response = new XmlRpcResponse(); |
89 | response.Value = reply.ToHashtable(); | 92 | response.Value = reply.ToHashtable(); |
@@ -109,10 +112,15 @@ namespace OpenSim.Server.Handlers.Login | |||
109 | if (map.ContainsKey("start")) | 112 | if (map.ContainsKey("start")) |
110 | startLocation = map["start"].AsString(); | 113 | startLocation = map["start"].AsString(); |
111 | 114 | ||
115 | UUID scopeID = UUID.Zero; | ||
116 | |||
117 | if (map.ContainsKey("scope_id")) | ||
118 | scopeID = new UUID(map["scope_id"].AsString()); | ||
119 | |||
112 | m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); | 120 | m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); |
113 | 121 | ||
114 | LoginResponse reply = null; | 122 | LoginResponse reply = null; |
115 | reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, remoteClient); | 123 | reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, scopeID, remoteClient); |
116 | return reply.ToOSDMap(); | 124 | return reply.ToOSDMap(); |
117 | 125 | ||
118 | } | 126 | } |
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index 0cc1978..edf224f 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs | |||
@@ -455,6 +455,35 @@ namespace OpenSim.Services.Connectors | |||
455 | return int.Parse(ret["RESULT"].ToString()); | 455 | return int.Parse(ret["RESULT"].ToString()); |
456 | } | 456 | } |
457 | 457 | ||
458 | public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID) | ||
459 | { | ||
460 | Dictionary<string, object> ret = MakeRequest("GETSYSTEMFOLDERS", | ||
461 | new Dictionary<string, object> { | ||
462 | { "PRINCIPAL", userID.ToString() }, | ||
463 | }); | ||
464 | |||
465 | if (ret == null) | ||
466 | return new Dictionary<AssetType,InventoryFolderBase>(); | ||
467 | |||
468 | Dictionary<AssetType, InventoryFolderBase> sfolders = new Dictionary<AssetType, InventoryFolderBase>(); | ||
469 | |||
470 | try | ||
471 | { | ||
472 | foreach (KeyValuePair<string, object> kvp in ret) | ||
473 | { | ||
474 | InventoryFolderBase folder = BuildFolder((Dictionary<string, object>)(kvp.Value)); | ||
475 | short type = 0; | ||
476 | if (Int16.TryParse(kvp.Key, out type)) | ||
477 | sfolders.Add((AssetType)type, folder); | ||
478 | } | ||
479 | } | ||
480 | catch (Exception e) | ||
481 | { | ||
482 | m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: exception {0}", e.Message); | ||
483 | } | ||
484 | |||
485 | return sfolders; | ||
486 | } | ||
458 | 487 | ||
459 | // These are either obsolete or unused | 488 | // These are either obsolete or unused |
460 | // | 489 | // |
diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs index 24bf342..49efbe2 100644 --- a/OpenSim/Services/Interfaces/ILoginService.cs +++ b/OpenSim/Services/Interfaces/ILoginService.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Net; | 31 | using System.Net; |
32 | 32 | ||
33 | using OpenMetaverse.StructuredData; | 33 | using OpenMetaverse.StructuredData; |
34 | using OpenMetaverse; | ||
34 | 35 | ||
35 | namespace OpenSim.Services.Interfaces | 36 | namespace OpenSim.Services.Interfaces |
36 | { | 37 | { |
@@ -46,7 +47,7 @@ namespace OpenSim.Services.Interfaces | |||
46 | 47 | ||
47 | public interface ILoginService | 48 | public interface ILoginService |
48 | { | 49 | { |
49 | LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP); | 50 | LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, IPEndPoint clientIP); |
50 | } | 51 | } |
51 | 52 | ||
52 | 53 | ||
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index c333b5c..4d7dfd1 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -147,7 +147,7 @@ namespace OpenSim.Services.LLLoginService | |||
147 | { | 147 | { |
148 | } | 148 | } |
149 | 149 | ||
150 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) | 150 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, UUID scopeID, IPEndPoint clientIP) |
151 | { | 151 | { |
152 | bool success = false; | 152 | bool success = false; |
153 | UUID session = UUID.Random(); | 153 | UUID session = UUID.Random(); |
@@ -157,7 +157,7 @@ namespace OpenSim.Services.LLLoginService | |||
157 | // | 157 | // |
158 | // Get the account and check that it exists | 158 | // Get the account and check that it exists |
159 | // | 159 | // |
160 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | 160 | UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName); |
161 | if (account == null) | 161 | if (account == null) |
162 | { | 162 | { |
163 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | 163 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); |
@@ -170,6 +170,22 @@ namespace OpenSim.Services.LLLoginService | |||
170 | return LLFailedLoginResponse.LoginBlockedProblem; | 170 | return LLFailedLoginResponse.LoginBlockedProblem; |
171 | } | 171 | } |
172 | 172 | ||
173 | // If a scope id is requested, check that the account is in | ||
174 | // that scope, or unscoped. | ||
175 | // | ||
176 | if (scopeID != UUID.Zero) | ||
177 | { | ||
178 | if (account.ScopeID != scopeID && account.ScopeID != UUID.Zero) | ||
179 | { | ||
180 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | ||
181 | return LLFailedLoginResponse.UserProblem; | ||
182 | } | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | scopeID = account.ScopeID; | ||
187 | } | ||
188 | |||
173 | // | 189 | // |
174 | // Authenticate this user | 190 | // Authenticate this user |
175 | // | 191 | // |
@@ -219,7 +235,7 @@ namespace OpenSim.Services.LLLoginService | |||
219 | // Get the home region | 235 | // Get the home region |
220 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) | 236 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) |
221 | { | 237 | { |
222 | home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); | 238 | home = m_GridService.GetRegionByUUID(scopeID, presence.HomeRegionID); |
223 | } | 239 | } |
224 | } | 240 | } |
225 | 241 | ||
@@ -230,7 +246,7 @@ namespace OpenSim.Services.LLLoginService | |||
230 | Vector3 position = Vector3.Zero; | 246 | Vector3 position = Vector3.Zero; |
231 | Vector3 lookAt = Vector3.Zero; | 247 | Vector3 lookAt = Vector3.Zero; |
232 | GridRegion gatekeeper = null; | 248 | GridRegion gatekeeper = null; |
233 | GridRegion destination = FindDestination(account, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt); | 249 | GridRegion destination = FindDestination(account, scopeID, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt); |
234 | if (destination == null) | 250 | if (destination == null) |
235 | { | 251 | { |
236 | m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); | 252 | m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); |
@@ -286,7 +302,7 @@ namespace OpenSim.Services.LLLoginService | |||
286 | } | 302 | } |
287 | } | 303 | } |
288 | 304 | ||
289 | protected GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) | 305 | protected GridRegion FindDestination(UserAccount account, UUID scopeID, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) |
290 | { | 306 | { |
291 | m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); | 307 | m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); |
292 | 308 | ||
@@ -318,7 +334,7 @@ namespace OpenSim.Services.LLLoginService | |||
318 | } | 334 | } |
319 | else | 335 | else |
320 | { | 336 | { |
321 | region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); | 337 | region = m_GridService.GetRegionByUUID(scopeID, pinfo.HomeRegionID); |
322 | 338 | ||
323 | if (null == region) | 339 | if (null == region) |
324 | { | 340 | { |
@@ -332,7 +348,7 @@ namespace OpenSim.Services.LLLoginService | |||
332 | 348 | ||
333 | if (tryDefaults) | 349 | if (tryDefaults) |
334 | { | 350 | { |
335 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | 351 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); |
336 | if (defaults != null && defaults.Count > 0) | 352 | if (defaults != null && defaults.Count > 0) |
337 | { | 353 | { |
338 | region = defaults[0]; | 354 | region = defaults[0]; |
@@ -342,7 +358,7 @@ namespace OpenSim.Services.LLLoginService | |||
342 | { | 358 | { |
343 | m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", | 359 | m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region", |
344 | account.FirstName, account.LastName); | 360 | account.FirstName, account.LastName); |
345 | defaults = m_GridService.GetRegionsByName(account.ScopeID, "", 1); | 361 | defaults = m_GridService.GetRegionsByName(scopeID, "", 1); |
346 | if (defaults != null && defaults.Count > 0) | 362 | if (defaults != null && defaults.Count > 0) |
347 | { | 363 | { |
348 | region = defaults[0]; | 364 | region = defaults[0]; |
@@ -363,9 +379,9 @@ namespace OpenSim.Services.LLLoginService | |||
363 | 379 | ||
364 | GridRegion region = null; | 380 | GridRegion region = null; |
365 | 381 | ||
366 | if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID)) == null) | 382 | if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.RegionID)) == null) |
367 | { | 383 | { |
368 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | 384 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); |
369 | if (defaults != null && defaults.Count > 0) | 385 | if (defaults != null && defaults.Count > 0) |
370 | { | 386 | { |
371 | region = defaults[0]; | 387 | region = defaults[0]; |
@@ -374,7 +390,7 @@ namespace OpenSim.Services.LLLoginService | |||
374 | else | 390 | else |
375 | { | 391 | { |
376 | m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); | 392 | m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); |
377 | defaults = m_GridService.GetRegionsByName(account.ScopeID, "", 1); | 393 | defaults = m_GridService.GetRegionsByName(scopeID, "", 1); |
378 | if (defaults != null && defaults.Count > 0) | 394 | if (defaults != null && defaults.Count > 0) |
379 | { | 395 | { |
380 | region = defaults[0]; | 396 | region = defaults[0]; |
@@ -414,11 +430,11 @@ namespace OpenSim.Services.LLLoginService | |||
414 | { | 430 | { |
415 | if (!regionName.Contains("@")) | 431 | if (!regionName.Contains("@")) |
416 | { | 432 | { |
417 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); | 433 | List<GridRegion> regions = m_GridService.GetRegionsByName(scopeID, regionName, 1); |
418 | if ((regions == null) || (regions != null && regions.Count == 0)) | 434 | if ((regions == null) || (regions != null && regions.Count == 0)) |
419 | { | 435 | { |
420 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName); | 436 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName); |
421 | regions = m_GridService.GetDefaultRegions(UUID.Zero); | 437 | regions = m_GridService.GetDefaultRegions(scopeID); |
422 | if (regions != null && regions.Count > 0) | 438 | if (regions != null && regions.Count > 0) |
423 | { | 439 | { |
424 | where = "safe"; | 440 | where = "safe"; |
@@ -461,7 +477,7 @@ namespace OpenSim.Services.LLLoginService | |||
461 | } | 477 | } |
462 | else | 478 | else |
463 | { | 479 | { |
464 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | 480 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); |
465 | if (defaults != null && defaults.Count > 0) | 481 | if (defaults != null && defaults.Count > 0) |
466 | { | 482 | { |
467 | where = "safe"; | 483 | where = "safe"; |