aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer.Config/AssemblyInfo.cs56
-rw-r--r--OpenSim/Grid/UserServer.Config/DbUserConfig.cs106
-rw-r--r--OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs550
-rw-r--r--OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs514
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs100
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginService.cs416
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserManager.cs718
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs132
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs176
-rw-r--r--OpenSim/Grid/UserServer/Main.cs316
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommandModule.cs375
-rw-r--r--OpenSim/Grid/UserServer/UserServerCommsManager.cs39
-rw-r--r--OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs142
14 files changed, 0 insertions, 3703 deletions
diff --git a/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs b/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs
deleted file mode 100644
index bd6b551..0000000
--- a/OpenSim/Grid/UserServer.Config/AssemblyInfo.cs
+++ /dev/null
@@ -1,56 +0,0 @@
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.Reflection;
29using System.Runtime.InteropServices;
30// Information about this assembly is defined by the following
31// attributes.
32//
33// change them to the information which is associated with the assembly
34// you compile.
35
36[assembly: AssemblyTitle("UserConfig")]
37[assembly: AssemblyDescription("")]
38[assembly: AssemblyConfiguration("")]
39[assembly: AssemblyCompany("http://opensimulator.org")]
40[assembly: AssemblyProduct("UserConfig")]
41[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
42[assembly: AssemblyTrademark("")]
43[assembly: AssemblyCulture("")]
44
45// This sets the default COM visibility of types in the assembly to invisible.
46// If you need to expose a type to COM, use [ComVisible(true)] on that type.
47[assembly: ComVisible(false)]
48
49// The assembly version has following format :
50//
51// Major.Minor.Build.Revision
52//
53// You can specify all values by your own or you can build default build and revision
54// numbers with the '*' character (the default):
55
56[assembly: AssemblyVersion("0.6.3.*")]
diff --git a/OpenSim/Grid/UserServer.Config/DbUserConfig.cs b/OpenSim/Grid/UserServer.Config/DbUserConfig.cs
deleted file mode 100644
index cbd0f0d..0000000
--- a/OpenSim/Grid/UserServer.Config/DbUserConfig.cs
+++ /dev/null
@@ -1,106 +0,0 @@
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 Db4objects.Db4o;
30using OpenSim.Framework.Configuration;
31using OpenSim.Framework.Console;
32using OpenSim.Framework.Interfaces;
33
34namespace OpenUser.Config.UserConfigDb4o
35{
36 public class Db4oConfigPlugin: IUserConfig
37 {
38 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
39
40 public UserConfig GetConfigObject()
41 {
42 m_log.Info("[DBUSERCONFIG]: Loading Db40Config dll");
43 return new DbUserConfig();
44 }
45 }
46
47 public class DbUserConfig : UserConfig
48 {
49 private IObjectContainer db;
50
51 public void LoadDefaults()
52 {
53 m_log.Info("DbUserConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
54
55 this.DefaultStartupMsg = m_log.CmdPrompt("Default startup message", "Welcome to OGS");
56
57 this.GridServerURL = m_log.CmdPrompt("Grid server URL","http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/");
58 this.GridSendKey = m_log.CmdPrompt("Key to send to grid server","null");
59 this.GridRecvKey = m_log.CmdPrompt("Key to expect from grid server","null");
60 }
61
62 public override void InitConfig()
63 {
64 try
65 {
66 db = Db4oFactory.OpenFile("openuser.yap");
67 IObjectSet result = db.Get(typeof(DbUserConfig));
68 if (result.Count == 1)
69 {
70 m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Found a UserConfig object in the local database, loading");
71 foreach (DbUserConfig cfg in result)
72 {
73 this.GridServerURL=cfg.GridServerURL;
74 this.GridSendKey=cfg.GridSendKey;
75 this.GridRecvKey=cfg.GridRecvKey;
76 this.DefaultStartupMsg=cfg.DefaultStartupMsg;
77 }
78 }
79 else
80 {
81 m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
82 LoadDefaults();
83 m_log.Info("[DBUSERCONFIG]: Writing out default settings to local database");
84 db.Set(this);
85 db.Close();
86 }
87 }
88 catch(Exception e)
89 {
90 m_log.Warn("DbUserConfig.cs:InitConfig() - Exception occured");
91 m_log.Warn(e.ToString());
92 }
93
94 m_log.Info("[DBUSERCONFIG]: User settings loaded:");
95 m_log.Info("[DBUSERCONFIG]: Default startup message: " + this.DefaultStartupMsg);
96 m_log.Info("[DBUSERCONFIG]: Grid server URL: " + this.GridServerURL);
97 m_log.Info("[DBUSERCONFIG]: Key to send to grid: " + this.GridSendKey);
98 m_log.Info("[DBUSERCONFIG]: Key to expect from grid: " + this.GridRecvKey);
99 }
100
101 public void Shutdown()
102 {
103 db.Close();
104 }
105 }
106}
diff --git a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs b/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs
deleted file mode 100644
index 923b06c..0000000
--- a/OpenSim/Grid/UserServer.Modules/AvatarCreationModule.cs
+++ /dev/null
@@ -1,550 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Grid.Framework;
42
43
44namespace OpenSim.Grid.UserServer.Modules
45{
46 public class AvatarCreationModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private UserDataBaseService m_userDataBaseService;
51 // private BaseHttpServer m_httpServer;
52 // TODO: unused: private UserConfig m_config;
53
54 private string m_inventoryServerUrl;
55 private IInterServiceInventoryServices m_inventoryService;
56
57 public AvatarCreationModule(UserDataBaseService userDataBaseService, UserConfig config, IInterServiceInventoryServices inventoryService)
58 {
59 // TODO: unused: m_config = config;
60 m_userDataBaseService = userDataBaseService;
61 m_inventoryService = inventoryService;
62 m_inventoryServerUrl = config.InventoryUrl.OriginalString;
63 }
64
65 public void Initialise(IGridServiceCore core)
66 {
67 CommandConsole console;
68 if (core.TryGet<CommandConsole>(out console))
69 {
70 console.Commands.AddCommand("userserver", false, "clone avatar",
71 "clone avatar <TemplateAvatarFirstName> <TemplateAvatarLastName> <TargetAvatarFirstName> <TargetAvatarLastName>",
72 "Clone the template avatar's inventory into a target avatar", RunCommand);
73 }
74 }
75
76 public void PostInitialise()
77 {
78
79 }
80
81 public void RegisterHandlers(BaseHttpServer httpServer)
82 {
83 }
84
85 public void RunCommand(string module, string[] cmd)
86 {
87 if ((cmd.Length == 6) && (cmd[0] == "clone") && (cmd[1] == "avatar"))
88 {
89 try
90 {
91 string tFirst = cmd[2];
92 string tLast = cmd[3];
93
94 string nFirst = cmd[4];
95 string nLast = cmd[5];
96
97 UserProfileData templateAvatar = m_userDataBaseService.GetUserProfile(tFirst, tLast);
98 UserProfileData newAvatar = m_userDataBaseService.GetUserProfile(nFirst, nLast);
99
100 if (templateAvatar == null)
101 {
102 m_log.ErrorFormat("[AvatarAppearance] Clone Avatar: Could not find template avatar {0} , {1}", tFirst, tLast);
103 return;
104 }
105
106 if (newAvatar == null)
107 {
108 m_log.ErrorFormat("[AvatarAppearance] Clone Avatar: Could not find target avatar {0} , {1}", nFirst, nLast);
109 return;
110 }
111 Guid avatar = newAvatar.ID.Guid;
112 Guid template = templateAvatar.ID.Guid;
113 CloneAvatar(avatar, template, true, true);
114
115 }
116 catch (Exception e)
117 {
118 m_log.Error("Error: " + e.ToString());
119 }
120 }
121 }
122 #region Avatar Appearance Creation
123
124 public bool CloneAvatar(Guid avatarID, Guid templateID, bool modifyPermissions, bool removeTargetsClothes)
125 {
126 m_log.InfoFormat("[AvatarAppearance] Starting to clone avatar {0} inventory to avatar {1}", templateID.ToString(), avatarID.ToString());
127 // TODO: unused: Guid bodyFolder = Guid.Empty;
128 // TODO: unused: Guid clothesFolder = Guid.Empty;
129 bool success = false;
130
131 UUID avID = new UUID(avatarID);
132 List<InventoryFolderBase> avatarInventory = m_inventoryService.GetInventorySkeleton(avID);
133 if ((avatarInventory == null) || (avatarInventory.Count == 0))
134 {
135 m_log.InfoFormat("[AvatarAppearance] No inventory found for user {0} , so creating it", avID.ToString());
136 m_inventoryService.CreateNewUserInventory(avID);
137 Thread.Sleep(5000);
138 avatarInventory = m_inventoryService.GetInventorySkeleton(avID);
139 }
140
141 if ((avatarInventory != null) && (avatarInventory.Count > 0))
142 {
143 UUID tempOwnID = new UUID(templateID);
144 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(tempOwnID);
145
146 if (removeTargetsClothes)
147 {
148 //remove clothes and attachments from target avatar so that the end result isn't a merger of its existing clothes
149 // and the clothes from the template avatar.
150 RemoveClothesAndAttachments(avID);
151 }
152
153 List<InventoryFolderBase> templateInventory = m_inventoryService.GetInventorySkeleton(tempOwnID);
154 if ((templateInventory != null) && (templateInventory.Count != 0))
155 {
156 for (int i = 0; i < templateInventory.Count; i++)
157 {
158 if (templateInventory[i].ParentID == UUID.Zero)
159 {
160 success = CloneFolder(avatarInventory, avID, UUID.Zero, appearance, templateInventory[i], templateInventory, modifyPermissions);
161 break;
162 }
163 }
164 }
165 else
166 {
167 m_log.InfoFormat("[AvatarAppearance] Failed to find the template owner's {0} inventory", tempOwnID);
168 }
169 }
170 m_log.InfoFormat("[AvatarAppearance] finished cloning avatar with result: {0}", success);
171 return success;
172 }
173
174 private bool CloneFolder(List<InventoryFolderBase> avatarInventory, UUID avID, UUID parentFolder, AvatarAppearance appearance, InventoryFolderBase templateFolder, List<InventoryFolderBase> templateFolders, bool modifyPermissions)
175 {
176 bool success = false;
177 UUID templateFolderId = templateFolder.ID;
178 if (templateFolderId != UUID.Zero)
179 {
180 InventoryFolderBase toFolder = FindFolder(templateFolder.Name, parentFolder.Guid, avatarInventory);
181 if (toFolder == null)
182 {
183 //create new folder
184 toFolder = new InventoryFolderBase();
185 toFolder.ID = UUID.Random();
186 toFolder.Name = templateFolder.Name;
187 toFolder.Owner = avID;
188 toFolder.Type = templateFolder.Type;
189 toFolder.Version = 1;
190 toFolder.ParentID = parentFolder;
191 if (!SynchronousRestObjectRequester.MakeRequest<InventoryFolderBase, bool>(
192 "POST", m_inventoryServerUrl + "CreateFolder/", toFolder))
193 {
194 m_log.InfoFormat("[AvatarApperance] Couldn't make new folder {0} in users inventory", toFolder.Name);
195 return false;
196 }
197 else
198 {
199 // m_log.InfoFormat("made new folder {0} in users inventory", toFolder.Name);
200 }
201 }
202
203 List<InventoryItemBase> templateItems = SynchronousRestObjectRequester.MakeRequest<Guid, List<InventoryItemBase>>(
204 "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid);
205 if ((templateItems != null) && (templateItems.Count > 0))
206 {
207 List<ClothesAttachment> wornClothes = new List<ClothesAttachment>();
208 List<ClothesAttachment> attachedItems = new List<ClothesAttachment>();
209
210 foreach (InventoryItemBase item in templateItems)
211 {
212
213 UUID clonedItemId = CloneInventoryItem(avID, toFolder.ID, item, modifyPermissions);
214 if (clonedItemId != UUID.Zero)
215 {
216 int appearanceType = ItemIsPartOfAppearance(item, appearance);
217 if (appearanceType >= 0)
218 {
219 // UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID);
220 wornClothes.Add(new ClothesAttachment(appearanceType, clonedItemId, item.AssetID));
221 }
222
223 if (appearance != null)
224 {
225 int attachment = appearance.GetAttachpoint(item.ID);
226 if (attachment > 0)
227 {
228 //UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID);
229 attachedItems.Add(new ClothesAttachment(attachment, clonedItemId, item.AssetID));
230 }
231 }
232 success = true;
233 }
234 }
235
236 if ((wornClothes.Count > 0) || (attachedItems.Count > 0))
237 {
238 //Update the worn clothes and attachments
239 AvatarAppearance targetAppearance = GetAppearance(avID);
240 if (targetAppearance != null)
241 {
242 foreach (ClothesAttachment wornItem in wornClothes)
243 {
244 targetAppearance.Wearables[wornItem.Type].AssetID = wornItem.AssetID;
245 targetAppearance.Wearables[wornItem.Type].ItemID = wornItem.ItemID;
246 }
247
248 foreach (ClothesAttachment wornItem in attachedItems)
249 {
250 targetAppearance.SetAttachment(wornItem.Type, wornItem.ItemID, wornItem.AssetID);
251 }
252
253 m_userDataBaseService.UpdateUserAppearance(avID, targetAppearance);
254 wornClothes.Clear();
255 attachedItems.Clear();
256 }
257 }
258 }
259 else if ((templateItems != null) && (templateItems.Count == 0))
260 {
261 // m_log.Info("[AvatarAppearance]Folder being cloned was empty");
262 success = true;
263 }
264
265 List<InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders);
266 foreach (InventoryFolderBase subFolder in subFolders)
267 {
268 if (subFolder.Name.ToLower() != "trash")
269 {
270 success = CloneFolder(avatarInventory, avID, toFolder.ID, appearance, subFolder, templateFolders, modifyPermissions);
271 }
272 }
273 }
274 else
275 {
276 m_log.Info("[AvatarAppearance] Failed to find the template folder");
277 }
278 return success;
279 }
280
281 private UUID CloneInventoryItem(UUID avatarID, UUID avatarFolder, InventoryItemBase item, bool modifyPerms)
282 {
283 if (avatarFolder != UUID.Zero)
284 {
285 InventoryItemBase clonedItem = new InventoryItemBase();
286 clonedItem.Owner = avatarID;
287 clonedItem.AssetID = item.AssetID;
288 clonedItem.AssetType = item.AssetType;
289 clonedItem.BasePermissions = item.BasePermissions;
290 clonedItem.CreationDate = item.CreationDate;
291 clonedItem.CreatorId = item.CreatorId;
292 clonedItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
293 clonedItem.CurrentPermissions = item.CurrentPermissions;
294 clonedItem.Description = item.Description;
295 clonedItem.EveryOnePermissions = item.EveryOnePermissions;
296 clonedItem.Flags = item.Flags;
297 clonedItem.Folder = avatarFolder;
298 clonedItem.GroupID = item.GroupID;
299 clonedItem.GroupOwned = item.GroupOwned;
300 clonedItem.GroupPermissions = item.GroupPermissions;
301 clonedItem.ID = UUID.Random();
302 clonedItem.InvType = item.InvType;
303 clonedItem.Name = item.Name;
304 clonedItem.NextPermissions = item.NextPermissions;
305 clonedItem.SalePrice = item.SalePrice;
306 clonedItem.SaleType = item.SaleType;
307
308 if (modifyPerms)
309 {
310 ModifyPermissions(ref clonedItem);
311 }
312
313 SynchronousRestObjectRequester.MakeRequest<InventoryItemBase, bool>(
314 "POST", m_inventoryServerUrl + "AddNewItem/", clonedItem);
315
316 return clonedItem.ID;
317 }
318
319 return UUID.Zero;
320 }
321
322 // TODO: unused
323 // private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID)
324 // {
325 // AvatarAppearance appearance = GetAppearance(avatarID);
326 // appearance.Wearables[wearableType].AssetID = assetID;
327 // appearance.Wearables[wearableType].ItemID = itemID;
328 // m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
329 // }
330
331 // TODO: unused
332 // private void UpdateAvatarAttachment(UUID avatarID, int attachmentPoint, UUID itemID, UUID assetID)
333 // {
334 // AvatarAppearance appearance = GetAppearance(avatarID);
335 // appearance.SetAttachment(attachmentPoint, itemID, assetID);
336 // m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
337 // }
338
339 private void RemoveClothesAndAttachments(UUID avatarID)
340 {
341 AvatarAppearance appearance = GetAppearance(avatarID);
342
343 appearance.ClearWearables();
344 appearance.ClearAttachments();
345 m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
346
347 }
348
349 private AvatarAppearance GetAppearance(UUID avatarID)
350 {
351 AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(avatarID);
352 if (appearance == null)
353 {
354 appearance = CreateDefaultAppearance(avatarID);
355 }
356 return appearance;
357 }
358
359 // TODO: unused
360 // private UUID FindFolderID(string name, List<InventoryFolderBase> folders)
361 // {
362 // foreach (InventoryFolderBase folder in folders)
363 // {
364 // if (folder.Name == name)
365 // {
366 // return folder.ID;
367 // }
368 // }
369 // return UUID.Zero;
370 // }
371
372 // TODO: unused
373 // private InventoryFolderBase FindFolder(string name, List<InventoryFolderBase> folders)
374 // {
375 // foreach (InventoryFolderBase folder in folders)
376 // {
377 // if (folder.Name == name)
378 // {
379 // return folder;
380 // }
381 // }
382 // return null;
383 // }
384
385 private InventoryFolderBase FindFolder(string name, Guid parentFolderID, List<InventoryFolderBase> folders)
386 {
387 foreach (InventoryFolderBase folder in folders)
388 {
389 if ((folder.Name == name) && (folder.ParentID.Guid == parentFolderID))
390 {
391 return folder;
392 }
393 }
394 return null;
395 }
396
397 // TODO: unused
398 // private InventoryItemBase GetItem(string itemName, List<InventoryItemBase> items)
399 // {
400 // foreach (InventoryItemBase item in items)
401 // {
402 // if (item.Name.ToLower() == itemName.ToLower())
403 // {
404 // return item;
405 // }
406 // }
407 // return null;
408 // }
409
410 private List<InventoryFolderBase> FindSubFolders(Guid parentFolderID, List<InventoryFolderBase> folders)
411 {
412 List<InventoryFolderBase> subFolders = new List<InventoryFolderBase>();
413 foreach (InventoryFolderBase folder in folders)
414 {
415 if (folder.ParentID.Guid == parentFolderID)
416 {
417 subFolders.Add(folder);
418 }
419 }
420 return subFolders;
421 }
422
423 protected virtual void ModifyPermissions(ref InventoryItemBase item)
424 {
425 // Propagate Permissions
426 item.BasePermissions = item.BasePermissions & item.NextPermissions;
427 item.CurrentPermissions = item.BasePermissions;
428 item.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions;
429 item.GroupPermissions = item.GroupPermissions & item.NextPermissions;
430
431 }
432
433 private AvatarAppearance CreateDefaultAppearance(UUID avatarId)
434 {
435 AvatarAppearance appearance = null;
436 AvatarWearable[] wearables;
437 byte[] visualParams;
438 GetDefaultAvatarAppearance(out wearables, out visualParams);
439 appearance = new AvatarAppearance(avatarId, wearables, visualParams);
440
441 return appearance;
442 }
443
444 private static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
445 {
446 visualParams = GetDefaultVisualParams();
447 wearables = AvatarWearable.DefaultWearables;
448 }
449
450 private static byte[] GetDefaultVisualParams()
451 {
452 byte[] visualParams;
453 visualParams = new byte[218];
454 for (int i = 0; i < 218; i++)
455 {
456 visualParams[i] = 100;
457 }
458 return visualParams;
459 }
460
461 private int ItemIsPartOfAppearance(InventoryItemBase item, AvatarAppearance appearance)
462 {
463 if (appearance != null)
464 {
465 if (appearance.BodyItem == item.ID)
466 return (int)WearableType.Shape;
467
468 if (appearance.EyesItem == item.ID)
469 return (int)WearableType.Eyes;
470
471 if (appearance.GlovesItem == item.ID)
472 return (int)WearableType.Gloves;
473
474 if (appearance.HairItem == item.ID)
475 return (int)WearableType.Hair;
476
477 if (appearance.JacketItem == item.ID)
478 return (int)WearableType.Jacket;
479
480 if (appearance.PantsItem == item.ID)
481 return (int)WearableType.Pants;
482
483 if (appearance.ShirtItem == item.ID)
484 return (int)WearableType.Shirt;
485
486 if (appearance.ShoesItem == item.ID)
487 return (int)WearableType.Shoes;
488
489 if (appearance.SkinItem == item.ID)
490 return (int)WearableType.Skin;
491
492 if (appearance.SkirtItem == item.ID)
493 return (int)WearableType.Skirt;
494
495 if (appearance.SocksItem == item.ID)
496 return (int)WearableType.Socks;
497
498 if (appearance.UnderPantsItem == item.ID)
499 return (int)WearableType.Underpants;
500
501 if (appearance.UnderShirtItem == item.ID)
502 return (int)WearableType.Undershirt;
503 }
504 return -1;
505 }
506 #endregion
507
508 public enum PermissionMask
509 {
510 None = 0,
511 Transfer = 8192,
512 Modify = 16384,
513 Copy = 32768,
514 Move = 524288,
515 Damage = 1048576,
516 All = 2147483647,
517 }
518
519 public enum WearableType
520 {
521 Shape = 0,
522 Skin = 1,
523 Hair = 2,
524 Eyes = 3,
525 Shirt = 4,
526 Pants = 5,
527 Shoes = 6,
528 Socks = 7,
529 Jacket = 8,
530 Gloves = 9,
531 Undershirt = 10,
532 Underpants = 11,
533 Skirt = 12,
534 }
535
536 public class ClothesAttachment
537 {
538 public int Type;
539 public UUID ItemID;
540 public UUID AssetID;
541
542 public ClothesAttachment(int type, UUID itemID, UUID assetID)
543 {
544 Type = type;
545 ItemID = itemID;
546 AssetID = assetID;
547 }
548 }
549 }
550} \ No newline at end of file
diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
deleted file mode 100644
index 3384952..0000000
--- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
+++ /dev/null
@@ -1,514 +0,0 @@
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.Collections;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Grid.Framework;
40
41namespace OpenSim.Grid.UserServer.Modules
42{
43 public enum NotificationRequest : int
44 {
45 Login = 0,
46 Logout = 1,
47 Shutdown = 2
48 }
49
50 public struct PresenceNotification
51 {
52 public NotificationRequest request;
53 public UUID agentID;
54 public UUID sessionID;
55 public UUID RegionID;
56 public ulong regionhandle;
57 public float positionX;
58 public float positionY;
59 public float positionZ;
60 public string firstname;
61 public string lastname;
62 }
63
64 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle);
65 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle);
66 public delegate void RegionStartupDelegate(UUID regionID);
67 public delegate void RegionShutdownDelegate(UUID regionID);
68
69
70 public class MessageServersConnector
71 {
72 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
73
74 public Dictionary<string, MessageServerInfo> MessageServers;
75
76 private BaseHttpServer m_httpServer;
77
78 private OpenSim.Framework.BlockingQueue<PresenceNotification> m_NotifyQueue =
79 new OpenSim.Framework.BlockingQueue<PresenceNotification>();
80
81 private IGridServiceCore m_core;
82
83 public event AgentLocationDelegate OnAgentLocation;
84 public event AgentLeavingDelegate OnAgentLeaving;
85 public event RegionStartupDelegate OnRegionStartup;
86 public event RegionShutdownDelegate OnRegionShutdown;
87
88 public MessageServersConnector()
89 {
90 MessageServers = new Dictionary<string, MessageServerInfo>();
91 }
92
93 public void Initialise(IGridServiceCore core)
94 {
95 m_core = core;
96 m_core.RegisterInterface<MessageServersConnector>(this);
97
98 Watchdog.StartThread(NotifyQueueRunner, "NotifyQueueRunner", ThreadPriority.Normal, true);
99 }
100
101 public void PostInitialise()
102 {
103 }
104
105 public void RegisterHandlers(BaseHttpServer httpServer)
106 {
107 m_httpServer = httpServer;
108
109 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup);
110 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown);
111 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation);
112 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving);
113 // Message Server ---> User Server
114 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
115 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion);
116 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
117 }
118
119 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
120 {
121 lock (MessageServers)
122 {
123 if (!MessageServers.ContainsKey(URI))
124 MessageServers.Add(URI, serverData);
125 }
126 }
127
128 public void DeRegisterMessageServer(string URI)
129 {
130 lock (MessageServers)
131 {
132 if (MessageServers.ContainsKey(URI))
133 MessageServers.Remove(URI);
134 }
135 }
136
137 public void AddResponsibleRegion(string URI, ulong regionhandle)
138 {
139 if (!MessageServers.ContainsKey(URI))
140 {
141 m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
142 }
143 else
144 {
145 MessageServerInfo msginfo = MessageServers["URI"];
146 msginfo.responsibleForRegions.Add(regionhandle);
147 MessageServers["URI"] = msginfo;
148 }
149 }
150 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
151 {
152 if (!MessageServers.ContainsKey(URI))
153 {
154 m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
155 }
156 else
157 {
158 MessageServerInfo msginfo = MessageServers["URI"];
159 if (msginfo.responsibleForRegions.Contains(regionhandle))
160 {
161 msginfo.responsibleForRegions.Remove(regionhandle);
162 MessageServers["URI"] = msginfo;
163 }
164 }
165
166 }
167 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request, IPEndPoint remoteClient)
168 {
169 XmlRpcResponse response = new XmlRpcResponse();
170 Hashtable requestData = (Hashtable)request.Params[0];
171 Hashtable responseData = new Hashtable();
172
173 if (requestData.Contains("uri"))
174 {
175 string URI = (string)requestData["uri"];
176 string sendkey=(string)requestData["sendkey"];
177 string recvkey=(string)requestData["recvkey"];
178 MessageServerInfo m = new MessageServerInfo();
179 m.URI = URI;
180 m.sendkey = sendkey;
181 m.recvkey = recvkey;
182 RegisterMessageServer(URI, m);
183 responseData["responsestring"] = "TRUE";
184 response.Value = responseData;
185 }
186 return response;
187 }
188 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request, IPEndPoint remoteClient)
189 {
190 XmlRpcResponse response = new XmlRpcResponse();
191 Hashtable requestData = (Hashtable)request.Params[0];
192 Hashtable responseData = new Hashtable();
193
194 if (requestData.Contains("uri"))
195 {
196 string URI = (string)requestData["uri"];
197
198 DeRegisterMessageServer(URI);
199 responseData["responsestring"] = "TRUE";
200 response.Value = responseData;
201 }
202 return response;
203 }
204
205 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request, IPEndPoint remoteClient)
206 {
207 XmlRpcResponse response = new XmlRpcResponse();
208 Hashtable requestData = (Hashtable)request.Params[0];
209 Hashtable responseData = new Hashtable();
210
211 if (requestData.Contains("fromuri"))
212 {
213 // string sURI = (string)requestData["fromuri"];
214 // string sagentID = (string)requestData["agentid"];
215 // string ssessionID = (string)requestData["sessionid"];
216 // string scurrentRegionID = (string)requestData["regionid"];
217 // string sregionhandle = (string)requestData["regionhandle"];
218 // string scurrentpos = (string)requestData["currentpos"];
219 //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos);
220 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
221
222 responseData["responsestring"] = "TRUE";
223 response.Value = responseData;
224 }
225 return response;
226 }
227
228 public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID,
229 ulong regionhandle, float positionX, float positionY,
230 float positionZ, string firstname, string lastname)
231 {
232 PresenceNotification notification = new PresenceNotification();
233
234 notification.request = NotificationRequest.Login;
235 notification.agentID = agentID;
236 notification.sessionID = sessionID;
237 notification.RegionID = RegionID;
238 notification.regionhandle = regionhandle;
239 notification.positionX = positionX;
240 notification.positionY = positionY;
241 notification.positionZ = positionZ;
242 notification.firstname = firstname;
243 notification.lastname = lastname;
244
245 m_NotifyQueue.Enqueue(notification);
246 }
247
248 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID,
249 ulong regionhandle, float positionX, float positionY,
250 float positionZ, string firstname, string lastname)
251 {
252 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D)
253 lock (MessageServers)
254 {
255 if (MessageServers.Count > 0)
256 {
257 m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
258 }
259// else
260// {
261// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
262// }
263 foreach (MessageServerInfo serv in MessageServers.Values)
264 {
265 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
266 regionhandle, positionX, positionY, positionZ,
267 firstname, lastname);
268 }
269 }
270 }
271
272 private void TellMessageServersAboutUserLogoffInternal(UUID agentID)
273 {
274 lock (MessageServers)
275 {
276 if (MessageServers.Count > 0)
277 {
278 m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers");
279 }
280 else
281 {
282// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
283 }
284 foreach (MessageServerInfo serv in MessageServers.Values)
285 {
286 NotifyMessageServerAboutUserLogoff(serv,agentID);
287 }
288 }
289 }
290
291 private void TellMessageServersAboutRegionShutdownInternal(UUID regionID)
292 {
293 lock (MessageServers)
294 {
295 if (MessageServers.Count > 0)
296 {
297 m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers");
298 }
299 else
300 {
301// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
302 }
303 foreach (MessageServerInfo serv in MessageServers.Values)
304 {
305 NotifyMessageServerAboutRegionShutdown(serv,regionID);
306 }
307 }
308 }
309
310 public void TellMessageServersAboutUserLogoff(UUID agentID)
311 {
312 PresenceNotification notification = new PresenceNotification();
313
314 notification.request = NotificationRequest.Logout;
315 notification.agentID = agentID;
316
317 m_NotifyQueue.Enqueue(notification);
318 }
319
320 public void TellMessageServersAboutRegionShutdown(UUID regionID)
321 {
322 PresenceNotification notification = new PresenceNotification();
323
324 notification.request = NotificationRequest.Shutdown;
325 notification.RegionID = regionID;
326
327 m_NotifyQueue.Enqueue(notification);
328 }
329
330 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID)
331 {
332 Hashtable reqparams = new Hashtable();
333 reqparams["sendkey"] = serv.sendkey;
334 reqparams["agentid"] = agentID.ToString();
335 ArrayList SendParams = new ArrayList();
336 SendParams.Add(reqparams);
337
338 XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams);
339 try
340 {
341 GridReq.Send(serv.URI, 6000);
342 }
343 catch (WebException)
344 {
345 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online");
346 }
347 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout");
348 }
349
350 private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID)
351 {
352 Hashtable reqparams = new Hashtable();
353 reqparams["sendkey"] = serv.sendkey;
354 reqparams["regionid"] = regionID.ToString();
355 ArrayList SendParams = new ArrayList();
356 SendParams.Add(reqparams);
357
358 XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams);
359 try
360 {
361 GridReq.Send(serv.URI, 6000);
362 }
363 catch (WebException)
364 {
365 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown.");
366 }
367 m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change");
368 }
369
370 private void NotifyMessageServerAboutUser(MessageServerInfo serv,
371 UUID agentID, UUID sessionID, UUID RegionID,
372 ulong regionhandle, float positionX, float positionY, float positionZ,
373 string firstname, string lastname)
374 {
375 Hashtable reqparams = new Hashtable();
376 reqparams["sendkey"] = serv.sendkey;
377 reqparams["agentid"] = agentID.ToString();
378 reqparams["sessionid"] = sessionID.ToString();
379 reqparams["regionid"] = RegionID.ToString();
380 reqparams["regionhandle"] = regionhandle.ToString();
381 reqparams["positionx"] = positionX.ToString();
382 reqparams["positiony"] = positionY.ToString();
383 reqparams["positionz"] = positionZ.ToString();
384 reqparams["firstname"] = firstname;
385 reqparams["lastname"] = lastname;
386
387 //reqparams["position"] = Position.ToString();
388
389 ArrayList SendParams = new ArrayList();
390 SendParams.Add(reqparams);
391
392 XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
393 try
394 {
395 GridReq.Send(serv.URI, 6000);
396 m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
397 }
398 catch (WebException)
399 {
400 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user");
401 }
402
403 }
404
405 private void NotifyQueueRunner()
406 {
407 while (true)
408 {
409 PresenceNotification presence = m_NotifyQueue.Dequeue();
410
411 if (presence.request == NotificationRequest.Shutdown)
412 {
413 TellMessageServersAboutRegionShutdownInternal(presence.RegionID);
414 }
415
416 if (presence.request == NotificationRequest.Login)
417 {
418 TellMessageServersAboutUserInternal(presence.agentID,
419 presence.sessionID, presence.RegionID,
420 presence.regionhandle, presence.positionX,
421 presence.positionY, presence.positionZ,
422 presence.firstname, presence.lastname);
423 }
424
425 if (presence.request == NotificationRequest.Logout)
426 {
427 TellMessageServersAboutUserLogoffInternal(presence.agentID);
428 }
429
430 Watchdog.UpdateThread();
431 }
432 }
433
434 public XmlRpcResponse RegionStartup(XmlRpcRequest request, IPEndPoint remoteClient)
435 {
436 Hashtable requestData = (Hashtable)request.Params[0];
437 Hashtable result = new Hashtable();
438
439 UUID regionID;
440 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
441 {
442 if (OnRegionStartup != null)
443 OnRegionStartup(regionID);
444
445 result["responsestring"] = "TRUE";
446 }
447
448 XmlRpcResponse response = new XmlRpcResponse();
449 response.Value = result;
450 return response;
451 }
452
453 public XmlRpcResponse RegionShutdown(XmlRpcRequest request, IPEndPoint remoteClient)
454 {
455 Hashtable requestData = (Hashtable)request.Params[0];
456 Hashtable result = new Hashtable();
457
458 UUID regionID;
459 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
460 {
461 if (OnRegionShutdown != null)
462 OnRegionShutdown(regionID);
463
464 result["responsestring"] = "TRUE";
465 }
466
467 XmlRpcResponse response = new XmlRpcResponse();
468 response.Value = result;
469 return response;
470 }
471
472 public XmlRpcResponse AgentLocation(XmlRpcRequest request, IPEndPoint remoteClient)
473 {
474 Hashtable requestData = (Hashtable)request.Params[0];
475 Hashtable result = new Hashtable();
476
477 UUID agentID;
478 UUID regionID;
479 ulong regionHandle;
480 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
481 {
482 if (OnAgentLocation != null)
483 OnAgentLocation(agentID, regionID, regionHandle);
484
485 result["responsestring"] = "TRUE";
486 }
487
488 XmlRpcResponse response = new XmlRpcResponse();
489 response.Value = result;
490 return response;
491 }
492
493 public XmlRpcResponse AgentLeaving(XmlRpcRequest request, IPEndPoint remoteClient)
494 {
495 Hashtable requestData = (Hashtable)request.Params[0];
496 Hashtable result = new Hashtable();
497
498 UUID agentID;
499 UUID regionID;
500 ulong regionHandle;
501 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
502 {
503 if (OnAgentLeaving != null)
504 OnAgentLeaving(agentID, regionID, regionHandle);
505
506 result["responsestring"] = "TRUE";
507 }
508
509 XmlRpcResponse response = new XmlRpcResponse();
510 response.Value = result;
511 return response;
512 }
513 }
514}
diff --git a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs b/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs
deleted file mode 100644
index 10d6f80..0000000
--- a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs
+++ /dev/null
@@ -1,100 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Grid.Framework;
40
41namespace OpenSim.Grid.UserServer.Modules
42{
43 public class UserDataBaseService : UserManagerBase
44 {
45 protected IGridServiceCore m_core;
46
47 public UserDataBaseService(CommunicationsManager commsManager)
48 : base(commsManager)
49 {
50 }
51
52 public void Initialise(IGridServiceCore core)
53 {
54 m_core = core;
55
56 UserConfig cfg;
57 if (m_core.TryGet<UserConfig>(out cfg))
58 {
59 AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect);
60 }
61
62 m_core.RegisterInterface<UserDataBaseService>(this);
63 }
64
65 public void PostInitialise()
66 {
67 }
68
69 public void RegisterHandlers(BaseHttpServer httpServer)
70 {
71 }
72
73 public UserAgentData GetUserAgentData(UUID AgentID)
74 {
75 UserProfileData userProfile = GetUserProfile(AgentID);
76
77 if (userProfile != null)
78 {
79 return userProfile.CurrentAgent;
80 }
81
82 return null;
83 }
84
85 public override UserProfileData SetupMasterUser(string firstName, string lastName)
86 {
87 throw new Exception("The method or operation is not implemented.");
88 }
89
90 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
91 {
92 throw new Exception("The method or operation is not implemented.");
93 }
94
95 public override UserProfileData SetupMasterUser(UUID uuid)
96 {
97 throw new Exception("The method or operation is not implemented.");
98 }
99 }
100}
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
deleted file mode 100644
index 97a919f..0000000
--- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
+++ /dev/null
@@ -1,416 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nwc.XmlRpc;
36using OpenMetaverse;
37using Nini.Config;
38using OpenSim.Data;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Services;
42using LoginResponse = OpenSim.Framework.Communications.Services.LoginResponse;
43using OpenSim.Framework.Communications.Cache;
44using OpenSim.Framework.Capabilities;
45using OpenSim.Framework.Servers;
46using OpenSim.Framework.Servers.HttpServer;
47using OpenSim.Services.Interfaces;
48using OpenSim.Services.Connectors;
49using GridRegion = OpenSim.Services.Interfaces.GridRegion;
50
51namespace OpenSim.Grid.UserServer.Modules
52{
53 public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID,
54 ulong regionhandle, float positionX, float positionY, float positionZ,
55 string firstname, string lastname);
56
57 /// <summary>
58 /// Login service used in grid mode.
59 /// </summary>
60 public class UserLoginService : LoginService
61 {
62 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
63
64 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
65
66 private UserLoggedInAtLocation handlerUserLoggedInAtLocation;
67
68 public UserConfig m_config;
69 private readonly IRegionProfileRouter m_regionProfileService;
70
71 private IGridService m_GridService;
72
73 protected BaseHttpServer m_httpServer;
74
75 public UserLoginService(
76 UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
77 LibraryRootFolder libraryRootFolder,
78 UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService)
79 : base(userManager, libraryRootFolder, welcomeMess)
80 {
81 m_config = config;
82 m_defaultHomeX = m_config.DefaultX;
83 m_defaultHomeY = m_config.DefaultY;
84 m_interInventoryService = inventoryService;
85 m_regionProfileService = regionProfileService;
86
87 m_GridService = new GridServicesConnector(config.GridServerURL.ToString());
88 }
89
90 public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
91 {
92 m_httpServer = httpServer;
93
94 m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod);
95 m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin);
96 m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams);
97 m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession, false);
98
99 if (registerLLSDHandler)
100 {
101 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod);
102 }
103
104 }
105
106 public void setloginlevel(int level)
107 {
108 m_minLoginLevel = level;
109 m_log.InfoFormat("[GRID]: Login Level set to {0} ", level);
110 }
111 public void setwelcometext(string text)
112 {
113 m_welcomeMessage = text;
114 m_log.InfoFormat("[GRID]: Login text set to {0} ", text);
115 }
116
117 public override void LogOffUser(UserProfileData theUser, string message)
118 {
119 RegionProfileData SimInfo;
120 try
121 {
122 SimInfo = m_regionProfileService.RequestSimProfileData(
123 theUser.CurrentAgent.Handle, m_config.GridServerURL,
124 m_config.GridSendKey, m_config.GridRecvKey);
125
126 if (SimInfo == null)
127 {
128 m_log.Error("[GRID]: Region user was in isn't currently logged in");
129 return;
130 }
131 }
132 catch (Exception)
133 {
134 m_log.Error("[GRID]: Unable to look up region to log user off");
135 return;
136 }
137
138 // Prepare notification
139 Hashtable SimParams = new Hashtable();
140 SimParams["agent_id"] = theUser.ID.ToString();
141 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
142 SimParams["region_secret2"] = SimInfo.regionSecret;
143 //m_log.Info(SimInfo.regionSecret);
144 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
145 SimParams["message"] = message;
146 ArrayList SendParams = new ArrayList();
147 SendParams.Add(SimParams);
148
149 m_log.InfoFormat(
150 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
151 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
152 theUser.FirstName + " " + theUser.SurName);
153
154 try
155 {
156 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
157 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
158
159 if (GridResp.IsFault)
160 {
161 m_log.ErrorFormat(
162 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
163 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
164 }
165 }
166 catch (Exception)
167 {
168 m_log.Error("[LOGIN]: Error telling region to logout user!");
169 }
170
171 // Prepare notification
172 SimParams = new Hashtable();
173 SimParams["agent_id"] = theUser.ID.ToString();
174 SimParams["region_secret"] = SimInfo.regionSecret;
175 //m_log.Info(SimInfo.regionSecret);
176 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
177 SimParams["message"] = message;
178 SendParams = new ArrayList();
179 SendParams.Add(SimParams);
180
181 m_log.InfoFormat(
182 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
183 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
184 theUser.FirstName + " " + theUser.SurName);
185
186 try
187 {
188 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
189 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
190
191 if (GridResp.IsFault)
192 {
193 m_log.ErrorFormat(
194 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
195 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
196 }
197 }
198 catch (Exception)
199 {
200 m_log.Error("[LOGIN]: Error telling region to logout user!");
201 }
202 //base.LogOffUser(theUser);
203 }
204
205 protected override RegionInfo RequestClosestRegion(string region)
206 {
207 return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region));
208 }
209
210 protected override RegionInfo GetRegionInfo(ulong homeRegionHandle)
211 {
212 uint x = 0, y = 0;
213 Utils.LongToUInts(homeRegionHandle, out x, out y);
214 return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y));
215 }
216
217 protected override RegionInfo GetRegionInfo(UUID homeRegionId)
218 {
219 return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId));
220 }
221
222 private RegionInfo GridRegionToRegionInfo(GridRegion gregion)
223 {
224 if (gregion == null)
225 return null;
226
227 RegionInfo rinfo = new RegionInfo();
228 rinfo.ExternalHostName = gregion.ExternalHostName;
229 rinfo.HttpPort = gregion.HttpPort;
230 rinfo.InternalEndPoint = gregion.InternalEndPoint;
231 rinfo.RegionID = gregion.RegionID;
232 rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize);
233 rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize);
234 rinfo.RegionName = gregion.RegionName;
235 rinfo.ScopeID = gregion.ScopeID;
236 rinfo.ServerURI = gregion.ServerURI;
237
238 return rinfo;
239 }
240
241 protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
242 {
243 return PrepareLoginToRegion(RegionProfileData.FromRegionInfo(regionInfo), user, response, remoteClient);
244 }
245
246 /// <summary>
247 /// Prepare a login to the given region. This involves both telling the region to expect a connection
248 /// and appropriately customising the response to the user.
249 /// </summary>
250 /// <param name="regionInfo"></param>
251 /// <param name="user"></param>
252 /// <param name="response"></param>
253 /// <returns>true if the region was successfully contacted, false otherwise</returns>
254 private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
255 {
256 try
257 {
258 response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString();
259 response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]);
260 response.RegionX = regionInfo.regionLocX;
261 response.RegionY = regionInfo.regionLocY;
262
263 string capsPath = CapsUtil.GetRandomCapsObjectPath();
264
265 // Adam's working code commented for now -- Diva 5/25/2009
266 //// For NAT
267 ////string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ServerIP);
268 //string host = response.SimAddress;
269 //// TODO: This doesnt support SSL. -Adam
270 //string serverURI = "http://" + host + ":" + regionInfo.ServerPort;
271
272 //response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath);
273
274 // Take off trailing / so that the caps path isn't //CAPS/someUUID
275 string uri = regionInfo.httpServerURI.Trim(new char[] { '/' });
276 response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath);
277
278
279 // Notify the target of an incoming user
280 m_log.InfoFormat(
281 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
282 regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI);
283
284 // Update agent with target sim
285 user.CurrentAgent.Region = regionInfo.UUID;
286 user.CurrentAgent.Handle = regionInfo.regionHandle;
287
288 // Prepare notification
289 Hashtable loginParams = new Hashtable();
290 loginParams["session_id"] = user.CurrentAgent.SessionID.ToString();
291 loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString();
292 loginParams["firstname"] = user.FirstName;
293 loginParams["lastname"] = user.SurName;
294 loginParams["agent_id"] = user.ID.ToString();
295 loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
296 loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString();
297 loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString();
298 loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString();
299 loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString();
300 loginParams["caps_path"] = capsPath;
301
302 // Get appearance
303 AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID);
304 if (appearance != null)
305 {
306 loginParams["appearance"] = appearance.ToHashTable();
307 m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName);
308 }
309 else
310 {
311 m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName);
312 appearance = new AvatarAppearance(user.ID);
313 loginParams["appearance"] = appearance.ToHashTable();
314 }
315
316 ArrayList SendParams = new ArrayList();
317 SendParams.Add(loginParams);
318
319 // Send
320 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
321 XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000);
322
323 if (!GridResp.IsFault)
324 {
325 bool responseSuccess = true;
326
327 if (GridResp.Value != null)
328 {
329 Hashtable resp = (Hashtable)GridResp.Value;
330 if (resp.ContainsKey("success"))
331 {
332 if ((string)resp["success"] == "FALSE")
333 {
334 responseSuccess = false;
335 }
336 }
337 }
338
339 if (responseSuccess)
340 {
341 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
342 if (handlerUserLoggedInAtLocation != null)
343 {
344 handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID,
345 user.CurrentAgent.Region,
346 user.CurrentAgent.Handle,
347 user.CurrentAgent.Position.X,
348 user.CurrentAgent.Position.Y,
349 user.CurrentAgent.Position.Z,
350 user.FirstName, user.SurName);
351 }
352 }
353 else
354 {
355 m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients");
356 return false;
357 }
358 }
359 else
360 {
361 m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode);
362 return false;
363 }
364 }
365 catch (Exception e)
366 {
367 m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e);
368 return false;
369 }
370
371 return true;
372 }
373
374 public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request, IPEndPoint remoteClient)
375 {
376 XmlRpcResponse response = new XmlRpcResponse();
377 Hashtable requestData = (Hashtable)request.Params[0];
378 UserProfileData userProfile;
379 Hashtable responseData = new Hashtable();
380
381 UUID uid;
382 string pass = requestData["password"].ToString();
383
384 if (!UUID.TryParse((string)requestData["avatar_uuid"], out uid))
385 {
386 responseData["error"] = "No authorization";
387 response.Value = responseData;
388 return response;
389 }
390
391 userProfile = m_userManager.GetUserProfile(uid);
392
393 if (userProfile == null ||
394 (!AuthenticateUser(userProfile, pass)) ||
395 userProfile.GodLevel < 200)
396 {
397 responseData["error"] = "No authorization";
398 response.Value = responseData;
399 return response;
400 }
401
402 if (requestData.ContainsKey("login_level"))
403 {
404 m_minLoginLevel = Convert.ToInt32(requestData["login_level"]);
405 }
406
407 if (requestData.ContainsKey("login_motd"))
408 {
409 m_welcomeMessage = requestData["login_motd"].ToString();
410 }
411
412 response.Value = responseData;
413 return response;
414 }
415 }
416}
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs
deleted file mode 100644
index 36c6297..0000000
--- a/OpenSim/Grid/UserServer.Modules/UserManager.cs
+++ /dev/null
@@ -1,718 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Grid.Framework;
41
42namespace OpenSim.Grid.UserServer.Modules
43{
44 public delegate void logOffUser(UUID AgentID);
45
46 public class UserManager
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 public event logOffUser OnLogOffUser;
51 private logOffUser handlerLogOffUser;
52
53 private UserDataBaseService m_userDataBaseService;
54 private BaseHttpServer m_httpServer;
55
56 /// <summary>
57 ///
58 /// </summary>
59 /// <param name="userDataBaseService"></param>
60 public UserManager(UserDataBaseService userDataBaseService)
61 {
62 m_userDataBaseService = userDataBaseService;
63 }
64
65 public void Initialise(IGridServiceCore core)
66 {
67
68 }
69
70 public void PostInitialise()
71 {
72
73 }
74
75 private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
76 {
77 UUID id;
78 UserProfileData userProfile;
79
80 try
81 {
82 id = new UUID(param);
83 }
84 catch (Exception)
85 {
86 httpResponse.StatusCode = 500;
87 return "Malformed Param [" + param + "]";
88 }
89
90 userProfile = m_userDataBaseService.GetUserProfile(id);
91
92 if (userProfile == null)
93 {
94 httpResponse.StatusCode = 404;
95 return "Not Found.";
96 }
97
98 return ProfileToXmlRPCResponse(userProfile).ToString();
99 }
100
101 public void RegisterHandlers(BaseHttpServer httpServer)
102 {
103 m_httpServer = httpServer;
104
105 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/users/", RESTGetUserProfile));
106
107 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName);
108 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
109 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
110
111 // Used by IAR module to do password checks
112 m_httpServer.AddXmlRPCHandler("authenticate_user_by_password", XmlRPCAuthenticateUserMethodPassword);
113
114 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
115 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
116 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
117
118 m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile);
119
120 m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod));
121 }
122
123 /// <summary>
124 /// Deletes an active agent session
125 /// </summary>
126 /// <param name="request">The request</param>
127 /// <param name="path">The path (eg /bork/narf/test)</param>
128 /// <param name="param">Parameters sent</param>
129 /// <param name="httpRequest">HTTP request header object</param>
130 /// <param name="httpResponse">HTTP response header object</param>
131 /// <returns>Success "OK" else error</returns>
132 public string RestDeleteUserSessionMethod(string request, string path, string param,
133 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
134 {
135 // TODO! Important!
136
137 return "OK";
138 }
139
140 public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers)
141 {
142 XmlRpcResponse response = new XmlRpcResponse();
143 Hashtable responseData = new Hashtable();
144 // Query Result Information
145 responseData["queryid"] = queryID.ToString();
146 responseData["avcount"] = returnUsers.Count.ToString();
147
148 for (int i = 0; i < returnUsers.Count; i++)
149 {
150 responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString();
151 responseData["firstname" + i] = returnUsers[i].firstName;
152 responseData["lastname" + i] = returnUsers[i].lastName;
153 }
154 response.Value = responseData;
155
156 return response;
157 }
158
159 /// <summary>
160 /// Converts a user profile to an XML element which can be returned
161 /// </summary>
162 /// <param name="profile">The user profile</param>
163 /// <returns>A string containing an XML Document of the user profile</returns>
164 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
165 {
166 XmlRpcResponse response = new XmlRpcResponse();
167 Hashtable responseData = new Hashtable();
168
169 // Account information
170 responseData["firstname"] = profile.FirstName;
171 responseData["lastname"] = profile.SurName;
172 responseData["email"] = profile.Email;
173 responseData["uuid"] = profile.ID.ToString();
174 // Server Information
175 responseData["server_inventory"] = profile.UserInventoryURI;
176 responseData["server_asset"] = profile.UserAssetURI;
177 // Profile Information
178 responseData["profile_about"] = profile.AboutText;
179 responseData["profile_firstlife_about"] = profile.FirstLifeAboutText;
180 responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString();
181 responseData["profile_can_do"] = profile.CanDoMask.ToString();
182 responseData["profile_want_do"] = profile.WantDoMask.ToString();
183 responseData["profile_image"] = profile.Image.ToString();
184 responseData["profile_created"] = profile.Created.ToString();
185 responseData["profile_lastlogin"] = profile.LastLogin.ToString();
186 // Home region information
187 responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString();
188 responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString();
189 responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString();
190
191 responseData["home_region"] = profile.HomeRegion.ToString();
192 responseData["home_region_id"] = profile.HomeRegionID.ToString();
193
194 responseData["home_look_x"] = profile.HomeLookAt.X.ToString();
195 responseData["home_look_y"] = profile.HomeLookAt.Y.ToString();
196 responseData["home_look_z"] = profile.HomeLookAt.Z.ToString();
197
198 responseData["user_flags"] = profile.UserFlags.ToString();
199 responseData["god_level"] = profile.GodLevel.ToString();
200 responseData["custom_type"] = profile.CustomType;
201 responseData["partner"] = profile.Partner.ToString();
202 response.Value = responseData;
203
204 return response;
205 }
206
207 #region XMLRPC User Methods
208
209 /// <summary>
210 /// Authenticate a user using their password
211 /// </summary>
212 /// <param name="request">Must contain values for "user_uuid" and "password" keys</param>
213 /// <param name="remoteClient"></param>
214 /// <returns></returns>
215 public XmlRpcResponse XmlRPCAuthenticateUserMethodPassword(XmlRpcRequest request, IPEndPoint remoteClient)
216 {
217// m_log.DebugFormat("[USER MANAGER]: Received authenticated user by password request from {0}", remoteClient);
218
219 Hashtable requestData = (Hashtable)request.Params[0];
220 string userUuidRaw = (string)requestData["user_uuid"];
221 string password = (string)requestData["password"];
222
223 if (null == userUuidRaw)
224 return Util.CreateUnknownUserErrorResponse();
225
226 UUID userUuid;
227 if (!UUID.TryParse(userUuidRaw, out userUuid))
228 return Util.CreateUnknownUserErrorResponse();
229
230 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(userUuid);
231 if (null == userProfile)
232 return Util.CreateUnknownUserErrorResponse();
233
234 string authed;
235
236 if (null == password)
237 {
238 authed = "FALSE";
239 }
240 else
241 {
242 if (m_userDataBaseService.AuthenticateUserByPassword(userUuid, password))
243 authed = "TRUE";
244 else
245 authed = "FALSE";
246 }
247
248// m_log.DebugFormat(
249// "[USER MANAGER]: Authentication by password result from {0} for {1} is {2}",
250// remoteClient, userUuid, authed);
251
252 XmlRpcResponse response = new XmlRpcResponse();
253 Hashtable responseData = new Hashtable();
254 responseData["auth_user"] = authed;
255 response.Value = responseData;
256
257 return response;
258 }
259
260 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request, IPEndPoint remoteClient)
261 {
262 // XmlRpcResponse response = new XmlRpcResponse();
263 Hashtable requestData = (Hashtable)request.Params[0];
264 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
265 UUID queryID = new UUID(UUID.Zero.ToString());
266
267 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
268 {
269 queryID = new UUID((string)requestData["queryid"]);
270 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string)requestData["avquery"]);
271 }
272
273 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]);
274 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
275 }
276
277 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request, IPEndPoint remoteClient)
278 {
279 XmlRpcResponse response = new XmlRpcResponse();
280 Hashtable requestData = (Hashtable)request.Params[0];
281 Hashtable responseData = new Hashtable();
282 string returnstring = "FALSE";
283
284 if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") &&
285 requestData.Contains("region_uuid"))
286 {
287 // ulong cregionhandle = 0;
288 UUID regionUUID;
289 UUID avatarUUID;
290
291 UUID.TryParse((string)requestData["avatar_id"], out avatarUUID);
292 UUID.TryParse((string)requestData["region_uuid"], out regionUUID);
293
294 if (avatarUUID != UUID.Zero)
295 {
296 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID);
297 userProfile.CurrentAgent.Region = regionUUID;
298 userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
299 //userProfile.CurrentAgent.
300 m_userDataBaseService.CommitAgent(ref userProfile);
301 //setUserProfile(userProfile);
302
303 returnstring = "TRUE";
304 }
305 }
306
307 responseData.Add("returnString", returnstring);
308 response.Value = responseData;
309 return response;
310 }
311
312 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request, IPEndPoint remoteClient)
313 {
314 // XmlRpcResponse response = new XmlRpcResponse();
315 Hashtable requestData = (Hashtable)request.Params[0];
316 UserProfileData userProfile;
317 if (requestData.Contains("avatar_name"))
318 {
319 string query = (string)requestData["avatar_name"];
320
321 if (null == query)
322 return Util.CreateUnknownUserErrorResponse();
323
324 // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
325
326 string[] querysplit = query.Split(' ');
327
328 if (querysplit.Length == 2)
329 {
330 userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]);
331 if (userProfile == null)
332 {
333 return Util.CreateUnknownUserErrorResponse();
334 }
335 }
336 else
337 {
338 return Util.CreateUnknownUserErrorResponse();
339 }
340 }
341 else
342 {
343 return Util.CreateUnknownUserErrorResponse();
344 }
345
346 return ProfileToXmlRPCResponse(userProfile);
347 }
348
349 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient)
350 {
351 // XmlRpcResponse response = new XmlRpcResponse();
352 Hashtable requestData = (Hashtable)request.Params[0];
353 UserProfileData userProfile;
354 //CFK: this clogs the UserServer log and is not necessary at this time.
355 //CFK: m_log.Debug("METHOD BY UUID CALLED");
356 if (requestData.Contains("avatar_uuid"))
357 {
358 try
359 {
360 UUID guess = new UUID((string)requestData["avatar_uuid"]);
361
362 userProfile = m_userDataBaseService.GetUserProfile(guess);
363 }
364 catch (FormatException)
365 {
366 return Util.CreateUnknownUserErrorResponse();
367 }
368
369 if (userProfile == null)
370 {
371 return Util.CreateUnknownUserErrorResponse();
372 }
373 }
374 else
375 {
376 return Util.CreateUnknownUserErrorResponse();
377 }
378
379 return ProfileToXmlRPCResponse(userProfile);
380 }
381
382 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient)
383 {
384 XmlRpcResponse response = new XmlRpcResponse();
385 Hashtable requestData = (Hashtable)request.Params[0];
386 UserProfileData userProfile;
387 //CFK: this clogs the UserServer log and is not necessary at this time.
388 //CFK: m_log.Debug("METHOD BY UUID CALLED");
389 if (requestData.Contains("avatar_uuid"))
390 {
391 UUID guess;
392
393 UUID.TryParse((string)requestData["avatar_uuid"], out guess);
394
395 if (guess == UUID.Zero)
396 {
397 return Util.CreateUnknownUserErrorResponse();
398 }
399
400 userProfile = m_userDataBaseService.GetUserProfile(guess);
401
402 if (userProfile == null)
403 {
404 return Util.CreateUnknownUserErrorResponse();
405 }
406
407 // no agent???
408 if (userProfile.CurrentAgent == null)
409 {
410 return Util.CreateUnknownUserErrorResponse();
411 }
412 Hashtable responseData = new Hashtable();
413
414 responseData["handle"] = userProfile.CurrentAgent.Handle.ToString();
415 responseData["session"] = userProfile.CurrentAgent.SessionID.ToString();
416 if (userProfile.CurrentAgent.AgentOnline)
417 responseData["agent_online"] = "TRUE";
418 else
419 responseData["agent_online"] = "FALSE";
420
421 response.Value = responseData;
422 }
423 else
424 {
425 return Util.CreateUnknownUserErrorResponse();
426 }
427
428 return response;
429 }
430
431 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request, IPEndPoint remoteClient)
432 {
433 m_log.Debug("[UserManager]: Got request to update user profile");
434 XmlRpcResponse response = new XmlRpcResponse();
435 Hashtable requestData = (Hashtable)request.Params[0];
436 Hashtable responseData = new Hashtable();
437
438 if (!requestData.Contains("avatar_uuid"))
439 {
440 return Util.CreateUnknownUserErrorResponse();
441 }
442
443 UUID UserUUID = new UUID((string)requestData["avatar_uuid"]);
444 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID);
445 if (null == userProfile)
446 {
447 return Util.CreateUnknownUserErrorResponse();
448 }
449 // don't know how yet.
450 if (requestData.Contains("AllowPublish"))
451 {
452 }
453 if (requestData.Contains("FLImageID"))
454 {
455 userProfile.FirstLifeImage = new UUID((string)requestData["FLImageID"]);
456 }
457 if (requestData.Contains("ImageID"))
458 {
459 userProfile.Image = new UUID((string)requestData["ImageID"]);
460 }
461 // dont' know how yet
462 if (requestData.Contains("MaturePublish"))
463 {
464 }
465 if (requestData.Contains("AboutText"))
466 {
467 userProfile.AboutText = (string)requestData["AboutText"];
468 }
469 if (requestData.Contains("FLAboutText"))
470 {
471 userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"];
472 }
473 // not in DB yet.
474 if (requestData.Contains("ProfileURL"))
475 {
476 }
477 if (requestData.Contains("home_region"))
478 {
479 try
480 {
481 userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]);
482 }
483 catch (ArgumentException)
484 {
485 m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument");
486 }
487 catch (FormatException)
488 {
489 m_log.Error("[PROFILE]:Failed to set home region, Invalid Format");
490 }
491 catch (OverflowException)
492 {
493 m_log.Error("[PROFILE]:Failed to set home region, Value was too large");
494 }
495 }
496 if (requestData.Contains("home_region_id"))
497 {
498 UUID regionID;
499 UUID.TryParse((string)requestData["home_region_id"], out regionID);
500 userProfile.HomeRegionID = regionID;
501 }
502 if (requestData.Contains("home_pos_x"))
503 {
504 try
505 {
506 userProfile.HomeLocationX = (float)Convert.ToDecimal((string)requestData["home_pos_x"]);
507 }
508 catch (InvalidCastException)
509 {
510 m_log.Error("[PROFILE]:Failed to set home postion x");
511 }
512 }
513 if (requestData.Contains("home_pos_y"))
514 {
515 try
516 {
517 userProfile.HomeLocationY = (float)Convert.ToDecimal((string)requestData["home_pos_y"]);
518 }
519 catch (InvalidCastException)
520 {
521 m_log.Error("[PROFILE]:Failed to set home postion y");
522 }
523 }
524 if (requestData.Contains("home_pos_z"))
525 {
526 try
527 {
528 userProfile.HomeLocationZ = (float)Convert.ToDecimal((string)requestData["home_pos_z"]);
529 }
530 catch (InvalidCastException)
531 {
532 m_log.Error("[PROFILE]:Failed to set home postion z");
533 }
534 }
535 if (requestData.Contains("home_look_x"))
536 {
537 try
538 {
539 userProfile.HomeLookAtX = (float)Convert.ToDecimal((string)requestData["home_look_x"]);
540 }
541 catch (InvalidCastException)
542 {
543 m_log.Error("[PROFILE]:Failed to set home lookat x");
544 }
545 }
546 if (requestData.Contains("home_look_y"))
547 {
548 try
549 {
550 userProfile.HomeLookAtY = (float)Convert.ToDecimal((string)requestData["home_look_y"]);
551 }
552 catch (InvalidCastException)
553 {
554 m_log.Error("[PROFILE]:Failed to set home lookat y");
555 }
556 }
557 if (requestData.Contains("home_look_z"))
558 {
559 try
560 {
561 userProfile.HomeLookAtZ = (float)Convert.ToDecimal((string)requestData["home_look_z"]);
562 }
563 catch (InvalidCastException)
564 {
565 m_log.Error("[PROFILE]:Failed to set home lookat z");
566 }
567 }
568 if (requestData.Contains("user_flags"))
569 {
570 try
571 {
572 userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]);
573 }
574 catch (InvalidCastException)
575 {
576 m_log.Error("[PROFILE]:Failed to set user flags");
577 }
578 }
579 if (requestData.Contains("god_level"))
580 {
581 try
582 {
583 userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]);
584 }
585 catch (InvalidCastException)
586 {
587 m_log.Error("[PROFILE]:Failed to set god level");
588 }
589 }
590 if (requestData.Contains("custom_type"))
591 {
592 try
593 {
594 userProfile.CustomType = (string)requestData["custom_type"];
595 }
596 catch (InvalidCastException)
597 {
598 m_log.Error("[PROFILE]:Failed to set custom type");
599 }
600 }
601 if (requestData.Contains("partner"))
602 {
603 try
604 {
605 userProfile.Partner = new UUID((string)requestData["partner"]);
606 }
607 catch (InvalidCastException)
608 {
609 m_log.Error("[PROFILE]:Failed to set partner");
610 }
611 }
612 else
613 {
614 userProfile.Partner = UUID.Zero;
615 }
616
617 // call plugin!
618 bool ret = m_userDataBaseService.UpdateUserProfile(userProfile);
619 responseData["returnString"] = ret.ToString();
620 response.Value = responseData;
621 return response;
622 }
623
624 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request, IPEndPoint remoteClient)
625 {
626 XmlRpcResponse response = new XmlRpcResponse();
627 Hashtable requestData = (Hashtable)request.Params[0];
628
629 if (requestData.Contains("avatar_uuid"))
630 {
631 try
632 {
633 UUID userUUID = new UUID((string)requestData["avatar_uuid"]);
634 UUID RegionID = new UUID((string)requestData["region_uuid"]);
635 ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
636 Vector3 position = new Vector3(
637 (float)Convert.ToDecimal((string)requestData["region_pos_x"]),
638 (float)Convert.ToDecimal((string)requestData["region_pos_y"]),
639 (float)Convert.ToDecimal((string)requestData["region_pos_z"]));
640 Vector3 lookat = new Vector3(
641 (float)Convert.ToDecimal((string)requestData["lookat_x"]),
642 (float)Convert.ToDecimal((string)requestData["lookat_y"]),
643 (float)Convert.ToDecimal((string)requestData["lookat_z"]));
644
645 handlerLogOffUser = OnLogOffUser;
646 if (handlerLogOffUser != null)
647 handlerLogOffUser(userUUID);
648
649 m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat);
650 }
651 catch (FormatException)
652 {
653 m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
654 return response;
655 }
656 }
657 else
658 {
659 return Util.CreateUnknownUserErrorResponse();
660 }
661
662 return response;
663 }
664
665 #endregion
666
667
668 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
669 {
670 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
671 if (userProfile != null)
672 {
673 userProfile.CurrentAgent.Region = regionID;
674 userProfile.CurrentAgent.Handle = regionHandle;
675 m_userDataBaseService.CommitAgent(ref userProfile);
676 }
677 }
678
679 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
680 {
681 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
682 if (userProfile != null)
683 {
684 if (userProfile.CurrentAgent.Region == regionID)
685 {
686 UserAgentData userAgent = userProfile.CurrentAgent;
687 if (userAgent != null && userAgent.AgentOnline)
688 {
689 userAgent.AgentOnline = false;
690 userAgent.LogoutTime = Util.UnixTimeSinceEpoch();
691 if (regionID != UUID.Zero)
692 {
693 userAgent.Region = regionID;
694 }
695 userAgent.Handle = regionHandle;
696 userProfile.LastLogin = userAgent.LogoutTime;
697
698 m_userDataBaseService.CommitAgent(ref userProfile);
699
700 handlerLogOffUser = OnLogOffUser;
701 if (handlerLogOffUser != null)
702 handlerLogOffUser(agentID);
703 }
704 }
705 }
706 }
707
708 public void HandleRegionStartup(UUID regionID)
709 {
710 m_userDataBaseService.LogoutUsers(regionID);
711 }
712
713 public void HandleRegionShutdown(UUID regionID)
714 {
715 m_userDataBaseService.LogoutUsers(regionID);
716 }
717 }
718}
diff --git a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
deleted file mode 100644
index 88918d1..0000000
--- a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
+++ /dev/null
@@ -1,132 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Grid.Framework;
41
42namespace OpenSim.Grid.UserServer.Modules
43{
44 public class UserServerAvatarAppearanceModule
45 {
46 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private UserDataBaseService m_userDataBaseService;
49 private BaseHttpServer m_httpServer;
50
51 public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService)
52 {
53 m_userDataBaseService = userDataBaseService;
54 }
55
56 public void Initialise(IGridServiceCore core)
57 {
58
59 }
60
61 public void PostInitialise()
62 {
63
64 }
65
66 public void RegisterHandlers(BaseHttpServer httpServer)
67 {
68 m_httpServer = httpServer;
69
70 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
71 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
72 }
73
74 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
75 {
76 XmlRpcResponse response = new XmlRpcResponse();
77 Hashtable requestData = (Hashtable)request.Params[0];
78 AvatarAppearance appearance;
79 Hashtable responseData;
80 if (requestData.Contains("owner"))
81 {
82 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
83 if (appearance == null)
84 {
85 responseData = new Hashtable();
86 responseData["error_type"] = "no appearance";
87 responseData["error_desc"] = "There was no appearance found for this avatar";
88 }
89 else
90 {
91 responseData = appearance.ToHashTable();
92 }
93 }
94 else
95 {
96 responseData = new Hashtable();
97 responseData["error_type"] = "unknown_avatar";
98 responseData["error_desc"] = "The avatar appearance requested is not in the database";
99 }
100
101 response.Value = responseData;
102 return response;
103 }
104
105 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
106 {
107 XmlRpcResponse response = new XmlRpcResponse();
108 Hashtable requestData = (Hashtable)request.Params[0];
109 Hashtable responseData;
110 if (requestData.Contains("owner"))
111 {
112 AvatarAppearance appearance = new AvatarAppearance(requestData);
113
114 // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when
115 // the TextureEntry is null. When that happens, this check can be removed
116 if (appearance.Texture != null)
117 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
118
119 responseData = new Hashtable();
120 responseData["returnString"] = "TRUE";
121 }
122 else
123 {
124 responseData = new Hashtable();
125 responseData["error_type"] = "unknown_avatar";
126 responseData["error_desc"] = "The avatar appearance requested is not in the database";
127 }
128 response.Value = responseData;
129 return response;
130 }
131 }
132}
diff --git a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs
deleted file mode 100644
index 56e52a0..0000000
--- a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs
+++ /dev/null
@@ -1,176 +0,0 @@
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 System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Grid.Framework;
41
42namespace OpenSim.Grid.UserServer.Modules
43{
44 public class UserServerFriendsModule
45 {
46 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private UserDataBaseService m_userDataBaseService;
49
50 private BaseHttpServer m_httpServer;
51
52 public UserServerFriendsModule(UserDataBaseService userDataBaseService)
53 {
54 m_userDataBaseService = userDataBaseService;
55 }
56
57 public void Initialise(IGridServiceCore core)
58 {
59
60 }
61
62 public void PostInitialise()
63 {
64
65 }
66
67 public void RegisterHandlers(BaseHttpServer httpServer)
68 {
69 m_httpServer = httpServer;
70
71 m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend);
72 m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend);
73 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms);
74 m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList);
75 }
76
77 public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
78 {
79 XmlRpcResponse response = new XmlRpcResponse();
80 Hashtable responseData = new Hashtable();
81 // Query Result Information
82
83 responseData["avcount"] = returnUsers.Count.ToString();
84
85 for (int i = 0; i < returnUsers.Count; i++)
86 {
87 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
88 responseData["friendID" + i] = returnUsers[i].Friend.ToString();
89 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
90 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
91 }
92 response.Value = responseData;
93
94 return response;
95 }
96
97 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request, IPEndPoint remoteClient)
98 {
99 XmlRpcResponse response = new XmlRpcResponse();
100 Hashtable requestData = (Hashtable)request.Params[0];
101 Hashtable responseData = new Hashtable();
102 string returnString = "FALSE";
103 // Query Result Information
104
105 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
106 requestData.Contains("friendPerms"))
107 {
108 // UserManagerBase.AddNewuserFriend
109 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]),
110 new UUID((string)requestData["friendID"]),
111 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
112 returnString = "TRUE";
113 }
114 responseData["returnString"] = returnString;
115 response.Value = responseData;
116 return response;
117 }
118
119 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request, IPEndPoint remoteClient)
120 {
121 XmlRpcResponse response = new XmlRpcResponse();
122 Hashtable requestData = (Hashtable)request.Params[0];
123 Hashtable responseData = new Hashtable();
124 string returnString = "FALSE";
125 // Query Result Information
126
127 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
128 {
129 // UserManagerBase.AddNewuserFriend
130 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]),
131 new UUID((string)requestData["friendID"]));
132 returnString = "TRUE";
133 }
134 responseData["returnString"] = returnString;
135 response.Value = responseData;
136 return response;
137 }
138
139 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request, IPEndPoint remoteClient)
140 {
141 XmlRpcResponse response = new XmlRpcResponse();
142 Hashtable requestData = (Hashtable)request.Params[0];
143 Hashtable responseData = new Hashtable();
144 string returnString = "FALSE";
145
146 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
147 requestData.Contains("friendPerms"))
148 {
149 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]),
150 new UUID((string)requestData["friendID"]),
151 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
152 // UserManagerBase.
153 returnString = "TRUE";
154 }
155 responseData["returnString"] = returnString;
156 response.Value = responseData;
157 return response;
158 }
159
160 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request, IPEndPoint remoteClient)
161 {
162 // XmlRpcResponse response = new XmlRpcResponse();
163 Hashtable requestData = (Hashtable)request.Params[0];
164 // Hashtable responseData = new Hashtable();
165
166 List<FriendListItem> returndata = new List<FriendListItem>();
167
168 if (requestData.Contains("ownerID"))
169 {
170 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"]));
171 }
172
173 return FriendListItemListtoXmlRPCResponse(returndata);
174 }
175 }
176}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
deleted file mode 100644
index d598728..0000000
--- a/OpenSim/Grid/UserServer/Main.cs
+++ /dev/null
@@ -1,316 +0,0 @@
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 System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46using Nini.Config;
47
48namespace OpenSim.Grid.UserServer
49{
50 /// <summary>
51 /// Grid user server main class
52 /// </summary>
53 public class OpenUser_Main : BaseOpenSimServer, IGridServiceCore
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 protected UserConfig Cfg;
58
59 protected UserDataBaseService m_userDataBaseService;
60
61 public UserManager m_userManager;
62
63 protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
64 protected UserServerFriendsModule m_friendsModule;
65
66 public UserLoginService m_loginService;
67 public MessageServersConnector m_messagesService;
68
69 protected UserServerCommandModule m_consoleCommandModule;
70 protected UserServerEventDispatchModule m_eventDispatcher;
71
72 protected AvatarCreationModule m_appearanceModule;
73
74 protected static string m_consoleType = "local";
75 protected static IConfigSource m_config = null;
76 protected static string m_configFile = "UserServer_Config.xml";
77
78 public static void Main(string[] args)
79 {
80 ArgvConfigSource argvSource = new ArgvConfigSource(args);
81 argvSource.AddSwitch("Startup", "console", "c");
82 argvSource.AddSwitch("Startup", "xmlfile", "x");
83
84 IConfig startupConfig = argvSource.Configs["Startup"];
85 if (startupConfig != null)
86 {
87 m_consoleType = startupConfig.GetString("console", "local");
88 m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml");
89 }
90
91 m_config = argvSource;
92
93 XmlConfigurator.Configure();
94
95 m_log.Info("Launching UserServer...");
96
97 OpenUser_Main userserver = new OpenUser_Main();
98
99 userserver.Startup();
100 userserver.Work();
101 }
102
103 public OpenUser_Main()
104 {
105 switch (m_consoleType)
106 {
107 case "rest":
108 m_console = new RemoteConsole("User");
109 break;
110 case "basic":
111 m_console = new CommandConsole("User");
112 break;
113 default:
114 m_console = new LocalConsole("User");
115 break;
116 }
117 MainConsole.Instance = m_console;
118 }
119
120 public void Work()
121 {
122 m_console.Output("Enter help for a list of commands\n");
123
124 while (true)
125 {
126 m_console.Prompt();
127 }
128 }
129
130 protected override void StartupSpecific()
131 {
132 IInterServiceInventoryServices inventoryService = StartupCoreComponents();
133
134 m_stats = StatsManager.StartCollectingUserStats();
135
136 //setup services/modules
137 StartupUserServerModules();
138
139 StartOtherComponents(inventoryService);
140
141 //PostInitialise the modules
142 PostInitialiseModules();
143
144 //register http handlers and start http server
145 m_log.Info("[STARTUP]: Starting HTTP process");
146 RegisterHttpHandlers();
147 m_httpServer.Start();
148
149 base.StartupSpecific();
150 }
151
152 protected virtual IInterServiceInventoryServices StartupCoreComponents()
153 {
154 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile)));
155
156 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
157
158 if (m_console is RemoteConsole)
159 {
160 RemoteConsole c = (RemoteConsole)m_console;
161 c.SetServer(m_httpServer);
162 IConfig netConfig = m_config.AddConfig("Network");
163 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
164 netConfig.Set("ConsolePass", Cfg.ConsolePass);
165 c.ReadConfig(m_config);
166 }
167
168 RegisterInterface<CommandConsole>(m_console);
169 RegisterInterface<UserConfig>(Cfg);
170
171 //Should be in modules?
172 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
173 // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
174
175 RegisterInterface<IInterServiceInventoryServices>(inventoryService);
176 // RegisterInterface<IRegionProfileRouter>(regionProfileService);
177
178 return inventoryService;
179 }
180
181 /// <summary>
182 /// Start up the user manager
183 /// </summary>
184 /// <param name="inventoryService"></param>
185 protected virtual void StartupUserServerModules()
186 {
187 m_log.Info("[STARTUP]: Establishing data connection");
188
189 //we only need core components so we can request them from here
190 IInterServiceInventoryServices inventoryService;
191 TryGet<IInterServiceInventoryServices>(out inventoryService);
192
193 CommunicationsManager commsManager = new UserServerCommsManager(inventoryService);
194
195 //setup database access service, for now this has to be created before the other modules.
196 m_userDataBaseService = new UserDataBaseService(commsManager);
197 m_userDataBaseService.Initialise(this);
198
199 //TODO: change these modules so they fetch the databaseService class in the PostInitialise method
200 m_userManager = new UserManager(m_userDataBaseService);
201 m_userManager.Initialise(this);
202
203 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
204 m_avatarAppearanceModule.Initialise(this);
205
206 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
207 m_friendsModule.Initialise(this);
208
209 m_consoleCommandModule = new UserServerCommandModule();
210 m_consoleCommandModule.Initialise(this);
211
212 m_messagesService = new MessageServersConnector();
213 m_messagesService.Initialise(this);
214 }
215
216 protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
217 {
218 m_appearanceModule = new AvatarCreationModule(m_userDataBaseService, Cfg, inventoryService);
219 m_appearanceModule.Initialise(this);
220
221 StartupLoginService(inventoryService);
222 //
223 // Get the minimum defaultLevel to access to the grid
224 //
225 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
226
227 RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
228
229 m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
230 m_eventDispatcher.Initialise(this);
231 }
232
233 /// <summary>
234 /// Start up the login service
235 /// </summary>
236 /// <param name="inventoryService"></param>
237 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
238 {
239 m_loginService = new UserLoginService(
240 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
241
242 }
243
244 protected virtual void PostInitialiseModules()
245 {
246 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
247 m_userDataBaseService.PostInitialise();
248 m_messagesService.PostInitialise();
249 m_eventDispatcher.PostInitialise(); //it will register event handlers in here
250 m_userManager.PostInitialise();
251 m_avatarAppearanceModule.PostInitialise();
252 m_friendsModule.PostInitialise();
253 }
254
255 protected virtual void RegisterHttpHandlers()
256 {
257 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
258
259 m_userManager.RegisterHandlers(m_httpServer);
260 m_friendsModule.RegisterHandlers(m_httpServer);
261 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
262 m_messagesService.RegisterHandlers(m_httpServer);
263 }
264
265 public override void ShutdownSpecific()
266 {
267 m_eventDispatcher.Close();
268 }
269
270 #region IUGAIMCore
271 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
272
273 /// <summary>
274 /// Register an Module interface.
275 /// </summary>
276 /// <typeparam name="T"></typeparam>
277 /// <param name="iface"></param>
278 public void RegisterInterface<T>(T iface)
279 {
280 lock (m_moduleInterfaces)
281 {
282 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
283 {
284 m_moduleInterfaces.Add(typeof(T), iface);
285 }
286 }
287 }
288
289 public bool TryGet<T>(out T iface)
290 {
291 if (m_moduleInterfaces.ContainsKey(typeof(T)))
292 {
293 iface = (T)m_moduleInterfaces[typeof(T)];
294 return true;
295 }
296 iface = default(T);
297 return false;
298 }
299
300 public T Get<T>()
301 {
302 return (T)m_moduleInterfaces[typeof(T)];
303 }
304
305 public BaseHttpServer GetHttpServer()
306 {
307 return m_httpServer;
308 }
309 #endregion
310
311 public void TestResponse(List<InventoryFolderBase> resp)
312 {
313 m_console.Output("response got");
314 }
315 }
316}
diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index ba79a55..0000000
--- a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
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.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34
35[assembly : AssemblyTitle("OGS-UserServer")]
36[assembly : AssemblyDescription("")]
37[assembly : AssemblyConfiguration("")]
38[assembly : AssemblyCompany("http://opensimulator.org")]
39[assembly : AssemblyProduct("OGS-UserServer")]
40[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47
48[assembly : ComVisible(false)]
49
50// The following GUID is for the ID of the typelib if this project is exposed to COM
51
52[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
53
54// Version information for an assembly consists of the following four values:
55//
56// Major Version
57// Minor Version
58// Build Number
59// Revision
60//
61
62[assembly : AssemblyVersion("0.6.5.*")]
63[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Grid/UserServer/UserServerCommandModule.cs b/OpenSim/Grid/UserServer/UserServerCommandModule.cs
deleted file mode 100644
index cca410e..0000000
--- a/OpenSim/Grid/UserServer/UserServerCommandModule.cs
+++ /dev/null
@@ -1,375 +0,0 @@
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 System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46
47namespace OpenSim.Grid.UserServer
48{
49 public class UserServerCommandModule
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected CommandConsole m_console;
54 protected UserConfig m_cfg;
55
56 protected UserDataBaseService m_userDataBaseService;
57 protected UserLoginService m_loginService;
58
59 protected UUID m_lastCreatedUser = UUID.Random();
60
61 protected IGridServiceCore m_core;
62
63 public UserServerCommandModule()
64 {
65 }
66
67 public void Initialise(IGridServiceCore core)
68 {
69 m_core = core;
70 }
71
72 public void PostInitialise()
73 {
74 UserConfig cfg;
75 if (m_core.TryGet<UserConfig>(out cfg))
76 {
77 m_cfg = cfg;
78 }
79
80 UserDataBaseService userDBservice;
81 if (m_core.TryGet<UserDataBaseService>(out userDBservice))
82 {
83 m_userDataBaseService = userDBservice;
84 }
85
86 UserLoginService loginService;
87 if (m_core.TryGet<UserLoginService>(out loginService))
88 {
89 m_loginService = loginService;
90 }
91
92 CommandConsole console;
93 if ((m_core.TryGet<CommandConsole>(out console)) && (m_cfg != null)
94 && (m_userDataBaseService != null) && (m_loginService != null))
95 {
96 RegisterConsoleCommands(console);
97 }
98 }
99
100 public void RegisterHandlers(BaseHttpServer httpServer)
101 {
102
103 }
104
105 private void RegisterConsoleCommands(CommandConsole console)
106 {
107 m_console = console;
108 m_console.Commands.AddCommand("userserver", false, "create user",
109 "create user [<first> [<last> [<x> <y> [email]]]]",
110 "Create a new user account", RunCommand);
111
112 m_console.Commands.AddCommand("userserver", false, "reset user password",
113 "reset user password [<first> [<last> [<new password>]]]",
114 "Reset a user's password", RunCommand);
115
116 m_console.Commands.AddCommand("userserver", false, "login level",
117 "login level <level>",
118 "Set the minimum user level to log in", HandleLoginCommand);
119
120 m_console.Commands.AddCommand("userserver", false, "login reset",
121 "login reset",
122 "Reset the login level to allow all users",
123 HandleLoginCommand);
124
125 m_console.Commands.AddCommand("userserver", false, "login text",
126 "login text <text>",
127 "Set the text users will see on login", HandleLoginCommand);
128
129 m_console.Commands.AddCommand("userserver", false, "test-inventory",
130 "test-inventory",
131 "Perform a test inventory transaction", RunCommand);
132
133 m_console.Commands.AddCommand("userserver", false, "logoff-user",
134 "logoff-user <first> <last> <message>",
135 "Log off a named user", RunCommand);
136 }
137
138 #region Console Command Handlers
139 public void do_create(string[] args)
140 {
141 switch (args[0])
142 {
143 case "user":
144 CreateUser(args);
145 break;
146 }
147 }
148
149 /// <summary>
150 /// Execute switch for some of the reset commands
151 /// </summary>
152 /// <param name="args"></param>
153 protected void Reset(string[] args)
154 {
155 if (args.Length == 0)
156 return;
157
158 switch (args[0])
159 {
160 case "user":
161
162 switch (args[1])
163 {
164 case "password":
165 ResetUserPassword(args);
166 break;
167 }
168
169 break;
170 }
171 }
172
173 /// <summary>
174 /// Create a new user
175 /// </summary>
176 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
177 protected void CreateUser(string[] cmdparams)
178 {
179 string firstName;
180 string lastName;
181 string password;
182 string email;
183 uint regX = 1000;
184 uint regY = 1000;
185
186 if (cmdparams.Length < 2)
187 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
188 else firstName = cmdparams[1];
189
190 if (cmdparams.Length < 3)
191 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
192 else lastName = cmdparams[2];
193
194 if (cmdparams.Length < 4)
195 password = MainConsole.Instance.PasswdPrompt("Password");
196 else password = cmdparams[3];
197
198 if (cmdparams.Length < 5)
199 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
200 else regX = Convert.ToUInt32(cmdparams[4]);
201
202 if (cmdparams.Length < 6)
203 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
204 else regY = Convert.ToUInt32(cmdparams[5]);
205
206 if (cmdparams.Length < 7)
207 email = MainConsole.Instance.CmdPrompt("Email", "");
208 else email = cmdparams[6];
209
210 if (null == m_userDataBaseService.GetUserProfile(firstName, lastName))
211 {
212 m_lastCreatedUser = m_userDataBaseService.AddUser(firstName, lastName, password, email, regX, regY);
213 }
214 else
215 {
216 m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
217 }
218 }
219
220 /// <summary>
221 /// Reset a user password.
222 /// </summary>
223 /// <param name="cmdparams"></param>
224 private void ResetUserPassword(string[] cmdparams)
225 {
226 string firstName;
227 string lastName;
228 string newPassword;
229
230 if (cmdparams.Length < 3)
231 firstName = MainConsole.Instance.CmdPrompt("First name");
232 else firstName = cmdparams[2];
233
234 if (cmdparams.Length < 4)
235 lastName = MainConsole.Instance.CmdPrompt("Last name");
236 else lastName = cmdparams[3];
237
238 if (cmdparams.Length < 5)
239 newPassword = MainConsole.Instance.PasswdPrompt("New password");
240 else newPassword = cmdparams[4];
241
242 m_userDataBaseService.ResetUserPassword(firstName, lastName, newPassword);
243 }
244
245 /*
246 private void HandleTestCommand(string module, string[] cmd)
247 {
248 m_log.Info("test command received");
249 }
250 */
251
252 private void HandleLoginCommand(string module, string[] cmd)
253 {
254 string subcommand = cmd[1];
255
256 switch (subcommand)
257 {
258 case "level":
259 // Set the minimal level to allow login
260 // Useful to allow grid update without worrying about users.
261 // or fixing critical issues
262 //
263 if (cmd.Length > 2)
264 {
265 int level = Convert.ToInt32(cmd[2]);
266 m_loginService.setloginlevel(level);
267 }
268 break;
269 case "reset":
270 m_loginService.setloginlevel(0);
271 break;
272 case "text":
273 if (cmd.Length > 2)
274 {
275 m_loginService.setwelcometext(cmd[2]);
276 }
277 break;
278 }
279 }
280
281 public void RunCommand(string module, string[] cmd)
282 {
283 List<string> args = new List<string>(cmd);
284 string command = cmd[0];
285
286 args.RemoveAt(0);
287
288 string[] cmdparams = args.ToArray();
289
290 switch (command)
291 {
292 case "create":
293 do_create(cmdparams);
294 break;
295
296 case "reset":
297 Reset(cmdparams);
298 break;
299
300
301 case "test-inventory":
302 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
303 // requester.ReturnResponseVal = TestResponse;
304 // requester.BeginPostObject<UUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
305 SynchronousRestObjectPoster.BeginPostObject<UUID, List<InventoryFolderBase>>(
306 "POST", m_cfg.InventoryUrl + "RootFolders/", m_lastCreatedUser);
307 break;
308
309 case "logoff-user":
310 if (cmdparams.Length >= 3)
311 {
312 string firstname = cmdparams[0];
313 string lastname = cmdparams[1];
314 string message = "";
315
316 for (int i = 2; i < cmdparams.Length; i++)
317 message += " " + cmdparams[i];
318
319 UserProfileData theUser = null;
320 try
321 {
322 theUser = m_loginService.GetTheUser(firstname, lastname);
323 }
324 catch (Exception)
325 {
326 m_log.Error("[LOGOFF]: Error getting user data from the database.");
327 }
328
329 if (theUser != null)
330 {
331 if (theUser.CurrentAgent != null)
332 {
333 if (theUser.CurrentAgent.AgentOnline)
334 {
335 m_log.Info("[LOGOFF]: Logging off requested user!");
336 m_loginService.LogOffUser(theUser, message);
337
338 theUser.CurrentAgent.AgentOnline = false;
339
340 m_loginService.CommitAgent(ref theUser);
341 }
342 else
343 {
344 m_log.Info(
345 "[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
346 m_loginService.LogOffUser(theUser, message);
347
348 theUser.CurrentAgent.AgentOnline = false;
349
350 m_loginService.CommitAgent(ref theUser);
351 }
352 }
353 else
354 {
355 m_log.Error(
356 "[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
357 }
358 }
359 else
360 {
361 m_log.Info("[LOGOFF]: User doesn't exist in the database");
362 }
363 }
364 else
365 {
366 m_log.Error(
367 "[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
368 }
369
370 break;
371 }
372 }
373 }
374 #endregion
375}
diff --git a/OpenSim/Grid/UserServer/UserServerCommsManager.cs b/OpenSim/Grid/UserServer/UserServerCommsManager.cs
deleted file mode 100644
index 7dc514c..0000000
--- a/OpenSim/Grid/UserServer/UserServerCommsManager.cs
+++ /dev/null
@@ -1,39 +0,0 @@
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 OpenSim.Framework.Communications;
29
30namespace OpenSim.Grid.UserServer
31{
32 public class UserServerCommsManager : CommunicationsManager
33 {
34 public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService)
35 : base(null, null)
36 {
37 }
38 }
39}
diff --git a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs b/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
deleted file mode 100644
index 0ad2f02..0000000
--- a/OpenSim/Grid/UserServer/UserServerEventDispatchModule.cs
+++ /dev/null
@@ -1,142 +0,0 @@
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 System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46
47namespace OpenSim.Grid.UserServer
48{
49 //Do we actually need these event dispatchers?
50 //shouldn't the other modules just directly register event handlers to each other?
51 public class UserServerEventDispatchModule
52 {
53 protected UserManager m_userManager;
54 protected MessageServersConnector m_messagesService;
55 protected UserLoginService m_loginService;
56
57 public UserServerEventDispatchModule(UserManager userManager, MessageServersConnector messagesService, UserLoginService loginService)
58 {
59 m_userManager = userManager;
60 m_messagesService = messagesService;
61 m_loginService = loginService;
62 }
63
64 public void Initialise(IGridServiceCore core)
65 {
66 }
67
68 public void PostInitialise()
69 {
70 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
71 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
72
73 m_messagesService.OnAgentLocation += HandleAgentLocation;
74 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
75 m_messagesService.OnRegionStartup += HandleRegionStartup;
76 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
77 }
78
79 public void RegisterHandlers(BaseHttpServer httpServer)
80 {
81
82 }
83
84 public void Close()
85 {
86 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
87 }
88
89 #region Event Handlers
90 public void NotifyMessageServersUserLoggOff(UUID agentID)
91 {
92 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
93 }
94
95 public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
96 ulong regionhandle, float positionX, float positionY,
97 float positionZ, string firstname, string lastname)
98 {
99 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
100 positionY, positionZ, firstname, lastname);
101 }
102
103 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
104 {
105 m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
106 }
107
108 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
109 {
110 m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
111 }
112
113 public void HandleRegionStartup(UUID regionID)
114 {
115 // This might seem strange, that we send this back to the
116 // server it came from. But there is method to the madness.
117 // There can be multiple user servers on the same database,
118 // and each can have multiple messaging servers. So, we send
119 // it to all known user servers, who send it to all known
120 // message servers. That way, we should be able to finally
121 // update presence to all regions and thereby all friends
122 //
123 m_userManager.HandleRegionStartup(regionID);
124 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
125 }
126
127 public void HandleRegionShutdown(UUID regionID)
128 {
129 // This might seem strange, that we send this back to the
130 // server it came from. But there is method to the madness.
131 // There can be multiple user servers on the same database,
132 // and each can have multiple messaging servers. So, we send
133 // it to all known user servers, who send it to all known
134 // message servers. That way, we should be able to finally
135 // update presence to all regions and thereby all friends
136 //
137 m_userManager.HandleRegionShutdown(regionID);
138 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
139 }
140 #endregion
141 }
142}