diff options
Diffstat (limited to '')
17 files changed, 108 insertions, 3930 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/GridInfoServiceModule.cs b/OpenSim/Data/Null/NullAuthenticationData.cs index 0c84348..3fb3105 100644 --- a/OpenSim/Grid/UserServer.Modules/GridInfoServiceModule.cs +++ b/OpenSim/Data/Null/NullAuthenticationData.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -26,54 +26,56 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | 31 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Data; |
37 | using OpenSim.Framework.Communications.Services; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Grid.Communications.OGS1; | ||
42 | using OpenSim.Grid.Framework; | ||
43 | 34 | ||
44 | namespace OpenSim.Grid.UserServer.Modules | 35 | namespace OpenSim.Data.Null |
45 | { | 36 | { |
46 | public class GridInfoServiceModule | 37 | public class NullAuthenticationData : IAuthenticationData |
47 | { | 38 | { |
48 | protected IGridServiceCore m_core; | 39 | private static Dictionary<UUID, AuthenticationData> m_DataByUUID = new Dictionary<UUID, AuthenticationData>(); |
49 | protected GridInfoService m_gridInfoService; | 40 | private static Dictionary<UUID, string> m_Tokens = new Dictionary<UUID, string>(); |
50 | protected BaseHttpServer m_httpServer; | ||
51 | 41 | ||
52 | public GridInfoServiceModule() | 42 | public NullAuthenticationData(string connectionString, string realm) |
53 | { | 43 | { |
54 | } | 44 | } |
55 | 45 | ||
56 | public void Initialise(IGridServiceCore core) | 46 | public AuthenticationData Get(UUID principalID) |
57 | { | 47 | { |
58 | m_core = core; | 48 | if (m_DataByUUID.ContainsKey(principalID)) |
59 | m_gridInfoService = new GridInfoService(); | 49 | return m_DataByUUID[principalID]; |
50 | |||
51 | return null; | ||
60 | } | 52 | } |
61 | 53 | ||
62 | public void PostInitialise() | 54 | public bool Store(AuthenticationData data) |
63 | { | 55 | { |
56 | m_DataByUUID[data.PrincipalID] = data; | ||
57 | return true; | ||
58 | } | ||
64 | 59 | ||
60 | public bool SetDataItem(UUID principalID, string item, string value) | ||
61 | { | ||
62 | // Not implemented | ||
63 | return false; | ||
65 | } | 64 | } |
66 | 65 | ||
67 | public void RegisterHandlers(BaseHttpServer httpServer) | 66 | public bool SetToken(UUID principalID, string token, int lifetime) |
68 | { | 67 | { |
69 | m_httpServer = httpServer; | 68 | m_Tokens[principalID] = token; |
70 | m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", | 69 | return true; |
71 | m_gridInfoService.RestGetGridInfoMethod)); | ||
72 | m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod); | ||
73 | } | 70 | } |
74 | 71 | ||
75 | public void Close() | 72 | public bool CheckToken(UUID principalID, string token, int lifetime) |
76 | { | 73 | { |
74 | if (m_Tokens.ContainsKey(principalID)) | ||
75 | return m_Tokens[principalID] == token; | ||
76 | |||
77 | return false; | ||
77 | } | 78 | } |
79 | |||
78 | } | 80 | } |
79 | } | 81 | } |
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 | |||
28 | using System.Reflection; | ||
29 | using 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 | |||
28 | using System; | ||
29 | using Db4objects.Db4o; | ||
30 | using OpenSim.Framework.Configuration; | ||
31 | using OpenSim.Framework.Console; | ||
32 | using OpenSim.Framework.Interfaces; | ||
33 | |||
34 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Servers; | ||
40 | using OpenSim.Framework.Servers.HttpServer; | ||
41 | using OpenSim.Grid.Framework; | ||
42 | |||
43 | |||
44 | namespace 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 | |||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | ||
39 | using OpenSim.Grid.Framework; | ||
40 | |||
41 | namespace 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/UserLoginAuthService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs deleted file mode 100644 index 77caf47..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs +++ /dev/null | |||
@@ -1,225 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Services; | ||
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Capabilities; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.HttpServer; | ||
44 | |||
45 | namespace OpenSim.Grid.UserServer.Modules | ||
46 | { | ||
47 | |||
48 | /// <summary> | ||
49 | /// Hypergrid login service used in grid mode. | ||
50 | /// </summary> | ||
51 | public class UserLoginAuthService : HGLoginAuthService | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | public UserConfig m_config; | ||
56 | private readonly IRegionProfileRouter m_regionProfileService; | ||
57 | |||
58 | protected BaseHttpServer m_httpServer; | ||
59 | |||
60 | public UserLoginAuthService( | ||
61 | UserManagerBase userManager, IInterServiceInventoryServices inventoryService, | ||
62 | LibraryRootFolder libraryRootFolder, | ||
63 | UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) | ||
64 | : base(userManager, welcomeMess, inventoryService, null, true, libraryRootFolder, null) | ||
65 | { | ||
66 | m_config = config; | ||
67 | m_defaultHomeX = m_config.DefaultX; | ||
68 | m_defaultHomeY = m_config.DefaultY; | ||
69 | m_interInventoryService = inventoryService; | ||
70 | m_regionProfileService = regionProfileService; | ||
71 | |||
72 | NetworkServersInfo serversinfo = new NetworkServersInfo(1000, 1000); | ||
73 | serversinfo.GridRecvKey = m_config.GridRecvKey; | ||
74 | serversinfo.GridSendKey = m_config.GridSendKey; | ||
75 | serversinfo.GridURL = m_config.GridServerURL.ToString(); | ||
76 | serversinfo.InventoryURL = m_config.InventoryUrl.ToString(); | ||
77 | serversinfo.UserURL = m_config.AuthUrl.ToString(); | ||
78 | SetServersInfo(serversinfo); | ||
79 | } | ||
80 | |||
81 | public void RegisterHandlers(BaseHttpServer httpServer) | ||
82 | { | ||
83 | m_httpServer = httpServer; | ||
84 | |||
85 | httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod); | ||
86 | httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod); | ||
87 | httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod); | ||
88 | } | ||
89 | |||
90 | |||
91 | public override void LogOffUser(UserProfileData theUser, string message) | ||
92 | { | ||
93 | RegionProfileData SimInfo; | ||
94 | try | ||
95 | { | ||
96 | SimInfo = m_regionProfileService.RequestSimProfileData( | ||
97 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
98 | m_config.GridSendKey, m_config.GridRecvKey); | ||
99 | |||
100 | if (SimInfo == null) | ||
101 | { | ||
102 | m_log.Error("[GRID]: Region user was in isn't currently logged in"); | ||
103 | return; | ||
104 | } | ||
105 | } | ||
106 | catch (Exception) | ||
107 | { | ||
108 | m_log.Error("[GRID]: Unable to look up region to log user off"); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | // Prepare notification | ||
113 | Hashtable SimParams = new Hashtable(); | ||
114 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
115 | SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); | ||
116 | SimParams["region_secret2"] = SimInfo.regionSecret; | ||
117 | //m_log.Info(SimInfo.regionSecret); | ||
118 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
119 | SimParams["message"] = message; | ||
120 | ArrayList SendParams = new ArrayList(); | ||
121 | SendParams.Add(SimParams); | ||
122 | |||
123 | m_log.InfoFormat( | ||
124 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
125 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
126 | theUser.FirstName + " " + theUser.SurName); | ||
127 | |||
128 | try | ||
129 | { | ||
130 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
131 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
132 | |||
133 | if (GridResp.IsFault) | ||
134 | { | ||
135 | m_log.ErrorFormat( | ||
136 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
137 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
138 | } | ||
139 | } | ||
140 | catch (Exception) | ||
141 | { | ||
142 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
143 | } | ||
144 | |||
145 | // Prepare notification | ||
146 | SimParams = new Hashtable(); | ||
147 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
148 | SimParams["region_secret"] = SimInfo.regionSecret; | ||
149 | //m_log.Info(SimInfo.regionSecret); | ||
150 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
151 | SimParams["message"] = message; | ||
152 | SendParams = new ArrayList(); | ||
153 | SendParams.Add(SimParams); | ||
154 | |||
155 | m_log.InfoFormat( | ||
156 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
157 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
158 | theUser.FirstName + " " + theUser.SurName); | ||
159 | |||
160 | try | ||
161 | { | ||
162 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
163 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
164 | |||
165 | if (GridResp.IsFault) | ||
166 | { | ||
167 | m_log.ErrorFormat( | ||
168 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
169 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
170 | } | ||
171 | } | ||
172 | catch (Exception) | ||
173 | { | ||
174 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
175 | } | ||
176 | //base.LogOffUser(theUser); | ||
177 | } | ||
178 | |||
179 | protected override RegionInfo RequestClosestRegion(string region) | ||
180 | { | ||
181 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, | ||
182 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
183 | |||
184 | if (profileData != null) | ||
185 | { | ||
186 | return profileData.ToRegionInfo(); | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | return null; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
195 | { | ||
196 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, | ||
197 | m_config.GridServerURL, m_config.GridSendKey, | ||
198 | m_config.GridRecvKey); | ||
199 | if (profileData != null) | ||
200 | { | ||
201 | return profileData.ToRegionInfo(); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | return null; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | ||
210 | { | ||
211 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, | ||
212 | m_config.GridServerURL, m_config.GridSendKey, | ||
213 | m_config.GridRecvKey); | ||
214 | if (profileData != null) | ||
215 | { | ||
216 | return profileData.ToRegionInfo(); | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | return null; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | } | ||
225 | } | ||
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs deleted file mode 100644 index d46ff9b..0000000 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ /dev/null | |||
@@ -1,423 +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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text.RegularExpressions; | ||
34 | using log4net; | ||
35 | using Nwc.XmlRpc; | ||
36 | using OpenMetaverse; | ||
37 | using Nini.Config; | ||
38 | using OpenSim.Data; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Services; | ||
42 | using OpenSim.Framework.Communications.Cache; | ||
43 | using OpenSim.Framework.Capabilities; | ||
44 | using OpenSim.Framework.Servers; | ||
45 | using OpenSim.Framework.Servers.HttpServer; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using OpenSim.Services.Connectors; | ||
48 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
49 | |||
50 | namespace OpenSim.Grid.UserServer.Modules | ||
51 | { | ||
52 | public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID, | ||
53 | ulong regionhandle, float positionX, float positionY, float positionZ, | ||
54 | string firstname, string lastname); | ||
55 | |||
56 | /// <summary> | ||
57 | /// Login service used in grid mode. | ||
58 | /// </summary> | ||
59 | public class UserLoginService : LoginService | ||
60 | { | ||
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
62 | |||
63 | public event UserLoggedInAtLocation OnUserLoggedInAtLocation; | ||
64 | |||
65 | private UserLoggedInAtLocation handlerUserLoggedInAtLocation; | ||
66 | |||
67 | public UserConfig m_config; | ||
68 | private readonly IRegionProfileRouter m_regionProfileService; | ||
69 | |||
70 | private IGridService m_GridService; | ||
71 | |||
72 | protected BaseHttpServer m_httpServer; | ||
73 | |||
74 | public UserLoginService( | ||
75 | UserManagerBase userManager, IInterServiceInventoryServices inventoryService, | ||
76 | LibraryRootFolder libraryRootFolder, | ||
77 | UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) | ||
78 | : base(userManager, libraryRootFolder, welcomeMess) | ||
79 | { | ||
80 | m_config = config; | ||
81 | m_defaultHomeX = m_config.DefaultX; | ||
82 | m_defaultHomeY = m_config.DefaultY; | ||
83 | m_interInventoryService = inventoryService; | ||
84 | m_regionProfileService = regionProfileService; | ||
85 | |||
86 | m_GridService = new GridServicesConnector(config.GridServerURL.ToString()); | ||
87 | } | ||
88 | |||
89 | public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) | ||
90 | { | ||
91 | m_httpServer = httpServer; | ||
92 | |||
93 | m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod); | ||
94 | m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin); | ||
95 | m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams); | ||
96 | m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession, false); | ||
97 | |||
98 | if (registerLLSDHandler) | ||
99 | { | ||
100 | m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod); | ||
101 | } | ||
102 | |||
103 | if (registerOpenIDHandlers) | ||
104 | { | ||
105 | // Handler for OpenID avatar identity pages | ||
106 | m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this)); | ||
107 | // Handlers for the OpenID endpoint server | ||
108 | m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this)); | ||
109 | m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this)); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | public void setloginlevel(int level) | ||
114 | { | ||
115 | m_minLoginLevel = level; | ||
116 | m_log.InfoFormat("[GRID]: Login Level set to {0} ", level); | ||
117 | } | ||
118 | public void setwelcometext(string text) | ||
119 | { | ||
120 | m_welcomeMessage = text; | ||
121 | m_log.InfoFormat("[GRID]: Login text set to {0} ", text); | ||
122 | } | ||
123 | |||
124 | public override void LogOffUser(UserProfileData theUser, string message) | ||
125 | { | ||
126 | RegionProfileData SimInfo; | ||
127 | try | ||
128 | { | ||
129 | SimInfo = m_regionProfileService.RequestSimProfileData( | ||
130 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
131 | m_config.GridSendKey, m_config.GridRecvKey); | ||
132 | |||
133 | if (SimInfo == null) | ||
134 | { | ||
135 | m_log.Error("[GRID]: Region user was in isn't currently logged in"); | ||
136 | return; | ||
137 | } | ||
138 | } | ||
139 | catch (Exception) | ||
140 | { | ||
141 | m_log.Error("[GRID]: Unable to look up region to log user off"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | // Prepare notification | ||
146 | Hashtable SimParams = new Hashtable(); | ||
147 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
148 | SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); | ||
149 | SimParams["region_secret2"] = SimInfo.regionSecret; | ||
150 | //m_log.Info(SimInfo.regionSecret); | ||
151 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
152 | SimParams["message"] = message; | ||
153 | ArrayList SendParams = new ArrayList(); | ||
154 | SendParams.Add(SimParams); | ||
155 | |||
156 | m_log.InfoFormat( | ||
157 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
158 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
159 | theUser.FirstName + " " + theUser.SurName); | ||
160 | |||
161 | try | ||
162 | { | ||
163 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
164 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
165 | |||
166 | if (GridResp.IsFault) | ||
167 | { | ||
168 | m_log.ErrorFormat( | ||
169 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
170 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
171 | } | ||
172 | } | ||
173 | catch (Exception) | ||
174 | { | ||
175 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
176 | } | ||
177 | |||
178 | // Prepare notification | ||
179 | SimParams = new Hashtable(); | ||
180 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
181 | SimParams["region_secret"] = SimInfo.regionSecret; | ||
182 | //m_log.Info(SimInfo.regionSecret); | ||
183 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
184 | SimParams["message"] = message; | ||
185 | SendParams = new ArrayList(); | ||
186 | SendParams.Add(SimParams); | ||
187 | |||
188 | m_log.InfoFormat( | ||
189 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
190 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
191 | theUser.FirstName + " " + theUser.SurName); | ||
192 | |||
193 | try | ||
194 | { | ||
195 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
196 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
197 | |||
198 | if (GridResp.IsFault) | ||
199 | { | ||
200 | m_log.ErrorFormat( | ||
201 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
202 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
203 | } | ||
204 | } | ||
205 | catch (Exception) | ||
206 | { | ||
207 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
208 | } | ||
209 | //base.LogOffUser(theUser); | ||
210 | } | ||
211 | |||
212 | protected override RegionInfo RequestClosestRegion(string region) | ||
213 | { | ||
214 | return GridRegionToRegionInfo(m_GridService.GetRegionByName(UUID.Zero, region)); | ||
215 | } | ||
216 | |||
217 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
218 | { | ||
219 | uint x = 0, y = 0; | ||
220 | Utils.LongToUInts(homeRegionHandle, out x, out y); | ||
221 | return GridRegionToRegionInfo(m_GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y)); | ||
222 | } | ||
223 | |||
224 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | ||
225 | { | ||
226 | return GridRegionToRegionInfo(m_GridService.GetRegionByUUID(UUID.Zero, homeRegionId)); | ||
227 | } | ||
228 | |||
229 | private RegionInfo GridRegionToRegionInfo(GridRegion gregion) | ||
230 | { | ||
231 | if (gregion == null) | ||
232 | return null; | ||
233 | |||
234 | RegionInfo rinfo = new RegionInfo(); | ||
235 | rinfo.ExternalHostName = gregion.ExternalHostName; | ||
236 | rinfo.HttpPort = gregion.HttpPort; | ||
237 | rinfo.InternalEndPoint = gregion.InternalEndPoint; | ||
238 | rinfo.RegionID = gregion.RegionID; | ||
239 | rinfo.RegionLocX = (uint)(gregion.RegionLocX / Constants.RegionSize); | ||
240 | rinfo.RegionLocY = (uint)(gregion.RegionLocY / Constants.RegionSize); | ||
241 | rinfo.RegionName = gregion.RegionName; | ||
242 | rinfo.ScopeID = gregion.ScopeID; | ||
243 | rinfo.ServerURI = gregion.ServerURI; | ||
244 | |||
245 | return rinfo; | ||
246 | } | ||
247 | |||
248 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) | ||
249 | { | ||
250 | return PrepareLoginToRegion(RegionProfileData.FromRegionInfo(regionInfo), user, response, remoteClient); | ||
251 | } | ||
252 | |||
253 | /// <summary> | ||
254 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | ||
255 | /// and appropriately customising the response to the user. | ||
256 | /// </summary> | ||
257 | /// <param name="regionInfo"></param> | ||
258 | /// <param name="user"></param> | ||
259 | /// <param name="response"></param> | ||
260 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | ||
261 | private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient) | ||
262 | { | ||
263 | try | ||
264 | { | ||
265 | response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); | ||
266 | response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); | ||
267 | response.RegionX = regionInfo.regionLocX; | ||
268 | response.RegionY = regionInfo.regionLocY; | ||
269 | |||
270 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
271 | |||
272 | // Adam's working code commented for now -- Diva 5/25/2009 | ||
273 | //// For NAT | ||
274 | ////string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ServerIP); | ||
275 | //string host = response.SimAddress; | ||
276 | //// TODO: This doesnt support SSL. -Adam | ||
277 | //string serverURI = "http://" + host + ":" + regionInfo.ServerPort; | ||
278 | |||
279 | //response.SeedCapability = serverURI + CapsUtil.GetCapsSeedPath(capsPath); | ||
280 | |||
281 | // Take off trailing / so that the caps path isn't //CAPS/someUUID | ||
282 | string uri = regionInfo.httpServerURI.Trim(new char[] { '/' }); | ||
283 | response.SeedCapability = uri + CapsUtil.GetCapsSeedPath(capsPath); | ||
284 | |||
285 | |||
286 | // Notify the target of an incoming user | ||
287 | m_log.InfoFormat( | ||
288 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | ||
289 | regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); | ||
290 | |||
291 | // Update agent with target sim | ||
292 | user.CurrentAgent.Region = regionInfo.UUID; | ||
293 | user.CurrentAgent.Handle = regionInfo.regionHandle; | ||
294 | |||
295 | // Prepare notification | ||
296 | Hashtable loginParams = new Hashtable(); | ||
297 | loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); | ||
298 | loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); | ||
299 | loginParams["firstname"] = user.FirstName; | ||
300 | loginParams["lastname"] = user.SurName; | ||
301 | loginParams["agent_id"] = user.ID.ToString(); | ||
302 | loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); | ||
303 | loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); | ||
304 | loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); | ||
305 | loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); | ||
306 | loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); | ||
307 | loginParams["caps_path"] = capsPath; | ||
308 | |||
309 | // Get appearance | ||
310 | AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID); | ||
311 | if (appearance != null) | ||
312 | { | ||
313 | loginParams["appearance"] = appearance.ToHashTable(); | ||
314 | m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName); | ||
315 | } | ||
316 | else | ||
317 | { | ||
318 | m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName); | ||
319 | appearance = new AvatarAppearance(user.ID); | ||
320 | loginParams["appearance"] = appearance.ToHashTable(); | ||
321 | } | ||
322 | |||
323 | ArrayList SendParams = new ArrayList(); | ||
324 | SendParams.Add(loginParams); | ||
325 | |||
326 | // Send | ||
327 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); | ||
328 | XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000); | ||
329 | |||
330 | if (!GridResp.IsFault) | ||
331 | { | ||
332 | bool responseSuccess = true; | ||
333 | |||
334 | if (GridResp.Value != null) | ||
335 | { | ||
336 | Hashtable resp = (Hashtable)GridResp.Value; | ||
337 | if (resp.ContainsKey("success")) | ||
338 | { | ||
339 | if ((string)resp["success"] == "FALSE") | ||
340 | { | ||
341 | responseSuccess = false; | ||
342 | } | ||
343 | } | ||
344 | } | ||
345 | |||
346 | if (responseSuccess) | ||
347 | { | ||
348 | handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; | ||
349 | if (handlerUserLoggedInAtLocation != null) | ||
350 | { | ||
351 | handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID, | ||
352 | user.CurrentAgent.Region, | ||
353 | user.CurrentAgent.Handle, | ||
354 | user.CurrentAgent.Position.X, | ||
355 | user.CurrentAgent.Position.Y, | ||
356 | user.CurrentAgent.Position.Z, | ||
357 | user.FirstName, user.SurName); | ||
358 | } | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients"); | ||
363 | return false; | ||
364 | } | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode); | ||
369 | return false; | ||
370 | } | ||
371 | } | ||
372 | catch (Exception e) | ||
373 | { | ||
374 | m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e); | ||
375 | return false; | ||
376 | } | ||
377 | |||
378 | return true; | ||
379 | } | ||
380 | |||
381 | public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request, IPEndPoint remoteClient) | ||
382 | { | ||
383 | XmlRpcResponse response = new XmlRpcResponse(); | ||
384 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
385 | UserProfileData userProfile; | ||
386 | Hashtable responseData = new Hashtable(); | ||
387 | |||
388 | UUID uid; | ||
389 | string pass = requestData["password"].ToString(); | ||
390 | |||
391 | if (!UUID.TryParse((string)requestData["avatar_uuid"], out uid)) | ||
392 | { | ||
393 | responseData["error"] = "No authorization"; | ||
394 | response.Value = responseData; | ||
395 | return response; | ||
396 | } | ||
397 | |||
398 | userProfile = m_userManager.GetUserProfile(uid); | ||
399 | |||
400 | if (userProfile == null || | ||
401 | (!AuthenticateUser(userProfile, pass)) || | ||
402 | userProfile.GodLevel < 200) | ||
403 | { | ||
404 | responseData["error"] = "No authorization"; | ||
405 | response.Value = responseData; | ||
406 | return response; | ||
407 | } | ||
408 | |||
409 | if (requestData.ContainsKey("login_level")) | ||
410 | { | ||
411 | m_minLoginLevel = Convert.ToInt32(requestData["login_level"]); | ||
412 | } | ||
413 | |||
414 | if (requestData.ContainsKey("login_motd")) | ||
415 | { | ||
416 | m_welcomeMessage = requestData["login_motd"].ToString(); | ||
417 | } | ||
418 | |||
419 | response.Value = responseData; | ||
420 | return response; | ||
421 | } | ||
422 | } | ||
423 | } | ||
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs deleted file mode 100644 index a2032dc..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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | |||
42 | namespace 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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo); | ||
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"], Culture.NumberFormatInfo), | ||
638 | (float)Convert.ToDecimal((string)requestData["region_pos_y"], Culture.NumberFormatInfo), | ||
639 | (float)Convert.ToDecimal((string)requestData["region_pos_z"], Culture.NumberFormatInfo)); | ||
640 | Vector3 lookat = new Vector3( | ||
641 | (float)Convert.ToDecimal((string)requestData["lookat_x"], Culture.NumberFormatInfo), | ||
642 | (float)Convert.ToDecimal((string)requestData["lookat_y"], Culture.NumberFormatInfo), | ||
643 | (float)Convert.ToDecimal((string)requestData["lookat_z"], Culture.NumberFormatInfo)); | ||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | |||
42 | namespace 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Servers; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | ||
40 | using OpenSim.Grid.Framework; | ||
41 | |||
42 | namespace 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 286076d7..0000000 --- a/OpenSim/Grid/UserServer/Main.cs +++ /dev/null | |||
@@ -1,330 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Framework.Statistics; | ||
43 | using OpenSim.Grid.Communications.OGS1; | ||
44 | using OpenSim.Grid.Framework; | ||
45 | using OpenSim.Grid.UserServer.Modules; | ||
46 | using Nini.Config; | ||
47 | |||
48 | namespace 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 UserLoginAuthService m_loginAuthService; | ||
68 | public MessageServersConnector m_messagesService; | ||
69 | |||
70 | protected GridInfoServiceModule m_gridInfoService; | ||
71 | |||
72 | protected UserServerCommandModule m_consoleCommandModule; | ||
73 | protected UserServerEventDispatchModule m_eventDispatcher; | ||
74 | |||
75 | protected AvatarCreationModule m_appearanceModule; | ||
76 | |||
77 | protected static string m_consoleType = "local"; | ||
78 | protected static IConfigSource m_config = null; | ||
79 | protected static string m_configFile = "UserServer_Config.xml"; | ||
80 | |||
81 | public static void Main(string[] args) | ||
82 | { | ||
83 | ArgvConfigSource argvSource = new ArgvConfigSource(args); | ||
84 | argvSource.AddSwitch("Startup", "console", "c"); | ||
85 | argvSource.AddSwitch("Startup", "xmlfile", "x"); | ||
86 | |||
87 | IConfig startupConfig = argvSource.Configs["Startup"]; | ||
88 | if (startupConfig != null) | ||
89 | { | ||
90 | m_consoleType = startupConfig.GetString("console", "local"); | ||
91 | m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml"); | ||
92 | } | ||
93 | |||
94 | m_config = argvSource; | ||
95 | |||
96 | XmlConfigurator.Configure(); | ||
97 | |||
98 | m_log.Info("Launching UserServer..."); | ||
99 | |||
100 | OpenUser_Main userserver = new OpenUser_Main(); | ||
101 | |||
102 | userserver.Startup(); | ||
103 | userserver.Work(); | ||
104 | } | ||
105 | |||
106 | public OpenUser_Main() | ||
107 | { | ||
108 | switch (m_consoleType) | ||
109 | { | ||
110 | case "rest": | ||
111 | m_console = new RemoteConsole("User"); | ||
112 | break; | ||
113 | case "basic": | ||
114 | m_console = new CommandConsole("User"); | ||
115 | break; | ||
116 | default: | ||
117 | m_console = new LocalConsole("User"); | ||
118 | break; | ||
119 | } | ||
120 | MainConsole.Instance = m_console; | ||
121 | } | ||
122 | |||
123 | public void Work() | ||
124 | { | ||
125 | m_console.Output("Enter help for a list of commands\n"); | ||
126 | |||
127 | while (true) | ||
128 | { | ||
129 | m_console.Prompt(); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | protected override void StartupSpecific() | ||
134 | { | ||
135 | IInterServiceInventoryServices inventoryService = StartupCoreComponents(); | ||
136 | |||
137 | m_stats = StatsManager.StartCollectingUserStats(); | ||
138 | |||
139 | //setup services/modules | ||
140 | StartupUserServerModules(); | ||
141 | |||
142 | StartOtherComponents(inventoryService); | ||
143 | |||
144 | //PostInitialise the modules | ||
145 | PostInitialiseModules(); | ||
146 | |||
147 | //register http handlers and start http server | ||
148 | m_log.Info("[STARTUP]: Starting HTTP process"); | ||
149 | RegisterHttpHandlers(); | ||
150 | m_httpServer.Start(); | ||
151 | |||
152 | base.StartupSpecific(); | ||
153 | } | ||
154 | |||
155 | protected virtual IInterServiceInventoryServices StartupCoreComponents() | ||
156 | { | ||
157 | Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile))); | ||
158 | |||
159 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); | ||
160 | |||
161 | if (m_console is RemoteConsole) | ||
162 | { | ||
163 | RemoteConsole c = (RemoteConsole)m_console; | ||
164 | c.SetServer(m_httpServer); | ||
165 | IConfig netConfig = m_config.AddConfig("Network"); | ||
166 | netConfig.Set("ConsoleUser", Cfg.ConsoleUser); | ||
167 | netConfig.Set("ConsolePass", Cfg.ConsolePass); | ||
168 | c.ReadConfig(m_config); | ||
169 | } | ||
170 | |||
171 | RegisterInterface<CommandConsole>(m_console); | ||
172 | RegisterInterface<UserConfig>(Cfg); | ||
173 | |||
174 | //Should be in modules? | ||
175 | IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); | ||
176 | // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy(); | ||
177 | |||
178 | RegisterInterface<IInterServiceInventoryServices>(inventoryService); | ||
179 | // RegisterInterface<IRegionProfileRouter>(regionProfileService); | ||
180 | |||
181 | return inventoryService; | ||
182 | } | ||
183 | |||
184 | /// <summary> | ||
185 | /// Start up the user manager | ||
186 | /// </summary> | ||
187 | /// <param name="inventoryService"></param> | ||
188 | protected virtual void StartupUserServerModules() | ||
189 | { | ||
190 | m_log.Info("[STARTUP]: Establishing data connection"); | ||
191 | |||
192 | //we only need core components so we can request them from here | ||
193 | IInterServiceInventoryServices inventoryService; | ||
194 | TryGet<IInterServiceInventoryServices>(out inventoryService); | ||
195 | |||
196 | CommunicationsManager commsManager = new UserServerCommsManager(inventoryService); | ||
197 | |||
198 | //setup database access service, for now this has to be created before the other modules. | ||
199 | m_userDataBaseService = new UserDataBaseService(commsManager); | ||
200 | m_userDataBaseService.Initialise(this); | ||
201 | |||
202 | //TODO: change these modules so they fetch the databaseService class in the PostInitialise method | ||
203 | m_userManager = new UserManager(m_userDataBaseService); | ||
204 | m_userManager.Initialise(this); | ||
205 | |||
206 | m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService); | ||
207 | m_avatarAppearanceModule.Initialise(this); | ||
208 | |||
209 | m_friendsModule = new UserServerFriendsModule(m_userDataBaseService); | ||
210 | m_friendsModule.Initialise(this); | ||
211 | |||
212 | m_consoleCommandModule = new UserServerCommandModule(); | ||
213 | m_consoleCommandModule.Initialise(this); | ||
214 | |||
215 | m_messagesService = new MessageServersConnector(); | ||
216 | m_messagesService.Initialise(this); | ||
217 | |||
218 | m_gridInfoService = new GridInfoServiceModule(); | ||
219 | m_gridInfoService.Initialise(this); | ||
220 | } | ||
221 | |||
222 | protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService) | ||
223 | { | ||
224 | m_appearanceModule = new AvatarCreationModule(m_userDataBaseService, Cfg, inventoryService); | ||
225 | m_appearanceModule.Initialise(this); | ||
226 | |||
227 | StartupLoginService(inventoryService); | ||
228 | // | ||
229 | // Get the minimum defaultLevel to access to the grid | ||
230 | // | ||
231 | m_loginService.setloginlevel((int)Cfg.DefaultUserLevel); | ||
232 | |||
233 | RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service | ||
234 | |||
235 | m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService); | ||
236 | m_eventDispatcher.Initialise(this); | ||
237 | } | ||
238 | |||
239 | /// <summary> | ||
240 | /// Start up the login service | ||
241 | /// </summary> | ||
242 | /// <param name="inventoryService"></param> | ||
243 | protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) | ||
244 | { | ||
245 | m_loginService = new UserLoginService( | ||
246 | m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | ||
247 | |||
248 | if (Cfg.EnableHGLogin) | ||
249 | m_loginAuthService = new UserLoginAuthService(m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), | ||
250 | Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | ||
251 | } | ||
252 | |||
253 | protected virtual void PostInitialiseModules() | ||
254 | { | ||
255 | m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here | ||
256 | m_userDataBaseService.PostInitialise(); | ||
257 | m_messagesService.PostInitialise(); | ||
258 | m_eventDispatcher.PostInitialise(); //it will register event handlers in here | ||
259 | m_gridInfoService.PostInitialise(); | ||
260 | m_userManager.PostInitialise(); | ||
261 | m_avatarAppearanceModule.PostInitialise(); | ||
262 | m_friendsModule.PostInitialise(); | ||
263 | } | ||
264 | |||
265 | protected virtual void RegisterHttpHandlers() | ||
266 | { | ||
267 | m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); | ||
268 | |||
269 | if (m_loginAuthService != null) | ||
270 | m_loginAuthService.RegisterHandlers(m_httpServer); | ||
271 | |||
272 | m_userManager.RegisterHandlers(m_httpServer); | ||
273 | m_friendsModule.RegisterHandlers(m_httpServer); | ||
274 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | ||
275 | m_messagesService.RegisterHandlers(m_httpServer); | ||
276 | m_gridInfoService.RegisterHandlers(m_httpServer); | ||
277 | } | ||
278 | |||
279 | public override void ShutdownSpecific() | ||
280 | { | ||
281 | m_eventDispatcher.Close(); | ||
282 | } | ||
283 | |||
284 | #region IUGAIMCore | ||
285 | protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>(); | ||
286 | |||
287 | /// <summary> | ||
288 | /// Register an Module interface. | ||
289 | /// </summary> | ||
290 | /// <typeparam name="T"></typeparam> | ||
291 | /// <param name="iface"></param> | ||
292 | public void RegisterInterface<T>(T iface) | ||
293 | { | ||
294 | lock (m_moduleInterfaces) | ||
295 | { | ||
296 | if (!m_moduleInterfaces.ContainsKey(typeof(T))) | ||
297 | { | ||
298 | m_moduleInterfaces.Add(typeof(T), iface); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | |||
303 | public bool TryGet<T>(out T iface) | ||
304 | { | ||
305 | if (m_moduleInterfaces.ContainsKey(typeof(T))) | ||
306 | { | ||
307 | iface = (T)m_moduleInterfaces[typeof(T)]; | ||
308 | return true; | ||
309 | } | ||
310 | iface = default(T); | ||
311 | return false; | ||
312 | } | ||
313 | |||
314 | public T Get<T>() | ||
315 | { | ||
316 | return (T)m_moduleInterfaces[typeof(T)]; | ||
317 | } | ||
318 | |||
319 | public BaseHttpServer GetHttpServer() | ||
320 | { | ||
321 | return m_httpServer; | ||
322 | } | ||
323 | #endregion | ||
324 | |||
325 | public void TestResponse(List<InventoryFolderBase> resp) | ||
326 | { | ||
327 | m_console.Output("response got"); | ||
328 | } | ||
329 | } | ||
330 | } | ||
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 | |||
28 | using System.Reflection; | ||
29 | using 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Framework.Statistics; | ||
43 | using OpenSim.Grid.Communications.OGS1; | ||
44 | using OpenSim.Grid.Framework; | ||
45 | using OpenSim.Grid.UserServer.Modules; | ||
46 | |||
47 | namespace 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 8ef693b..0000000 --- a/OpenSim/Grid/UserServer/UserServerCommsManager.cs +++ /dev/null | |||
@@ -1,40 +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 | |||
28 | using OpenSim.Framework.Communications; | ||
29 | |||
30 | namespace OpenSim.Grid.UserServer | ||
31 | { | ||
32 | public class UserServerCommsManager : CommunicationsManager | ||
33 | { | ||
34 | public UserServerCommsManager(IInterServiceInventoryServices interServiceInventoryService) | ||
35 | : base(null, null) | ||
36 | { | ||
37 | m_interServiceInventoryService = interServiceInventoryService; | ||
38 | } | ||
39 | } | ||
40 | } | ||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using log4net.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Framework.Servers.HttpServer; | ||
42 | using OpenSim.Framework.Statistics; | ||
43 | using OpenSim.Grid.Communications.OGS1; | ||
44 | using OpenSim.Grid.Framework; | ||
45 | using OpenSim.Grid.UserServer.Modules; | ||
46 | |||
47 | namespace 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 | } | ||
diff --git a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs index 10d6f80..6d975af 100644 --- a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -26,75 +26,94 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
32 | using log4net; | 31 | using log4net; |
33 | using Nwc.XmlRpc; | 32 | using Nini.Config; |
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | using OpenSim.Framework.Servers.HttpServer; | 34 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Grid.Framework; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Server.Handlers.Base; | ||
39 | using OpenSim.Server.Handlers.Grid; | ||
40 | using OpenSim.Services.Interfaces; | ||
40 | 41 | ||
41 | namespace OpenSim.Grid.UserServer.Modules | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid |
42 | { | 43 | { |
43 | public class UserDataBaseService : UserManagerBase | 44 | public class GridInfoServiceInConnectorModule : ISharedRegionModule |
44 | { | 45 | { |
45 | protected IGridServiceCore m_core; | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private static bool m_Enabled = false; | ||
48 | |||
49 | private IConfigSource m_Config; | ||
50 | bool m_Registered = false; | ||
46 | 51 | ||
47 | public UserDataBaseService(CommunicationsManager commsManager) | 52 | #region IRegionModule interface |
48 | : base(commsManager) | ||
49 | { | ||
50 | } | ||
51 | 53 | ||
52 | public void Initialise(IGridServiceCore core) | 54 | public void Initialise(IConfigSource config) |
53 | { | 55 | { |
54 | m_core = core; | 56 | m_Config = config; |
55 | 57 | IConfig moduleConfig = config.Configs["Modules"]; | |
56 | UserConfig cfg; | 58 | if (moduleConfig != null) |
57 | if (m_core.TryGet<UserConfig>(out cfg)) | ||
58 | { | 59 | { |
59 | AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect); | 60 | m_Enabled = moduleConfig.GetBoolean("GridInfoServiceInConnector", false); |
61 | if (m_Enabled) | ||
62 | { | ||
63 | m_log.Info("[GRIDINFO IN CONNECTOR]: GridInfo Service In Connector enabled"); | ||
64 | } | ||
65 | |||
60 | } | 66 | } |
61 | 67 | ||
62 | m_core.RegisterInterface<UserDataBaseService>(this); | ||
63 | } | 68 | } |
64 | 69 | ||
65 | public void PostInitialise() | 70 | public void PostInitialise() |
66 | { | 71 | { |
67 | } | 72 | } |
68 | 73 | ||
69 | public void RegisterHandlers(BaseHttpServer httpServer) | 74 | public void Close() |
70 | { | 75 | { |
71 | } | 76 | } |
72 | 77 | ||
73 | public UserAgentData GetUserAgentData(UUID AgentID) | 78 | public Type ReplaceableInterface |
74 | { | 79 | { |
75 | UserProfileData userProfile = GetUserProfile(AgentID); | 80 | get { return null; } |
76 | 81 | } | |
77 | if (userProfile != null) | ||
78 | { | ||
79 | return userProfile.CurrentAgent; | ||
80 | } | ||
81 | 82 | ||
82 | return null; | 83 | public string Name |
84 | { | ||
85 | get { return "GridInfoService"; } | ||
83 | } | 86 | } |
84 | 87 | ||
85 | public override UserProfileData SetupMasterUser(string firstName, string lastName) | 88 | public void AddRegion(Scene scene) |
86 | { | 89 | { |
87 | throw new Exception("The method or operation is not implemented."); | 90 | if (!m_Enabled) |
91 | return; | ||
88 | } | 92 | } |
89 | 93 | ||
90 | public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) | 94 | public void RemoveRegion(Scene scene) |
91 | { | 95 | { |
92 | throw new Exception("The method or operation is not implemented."); | 96 | if (!m_Enabled) |
97 | return; | ||
93 | } | 98 | } |
94 | 99 | ||
95 | public override UserProfileData SetupMasterUser(UUID uuid) | 100 | public void RegionLoaded(Scene scene) |
96 | { | 101 | { |
97 | throw new Exception("The method or operation is not implemented."); | 102 | if (!m_Enabled) |
103 | return; | ||
104 | |||
105 | if (!m_Registered) | ||
106 | { | ||
107 | m_Registered = true; | ||
108 | |||
109 | m_log.Info("[GridInfo]: Starting..."); | ||
110 | |||
111 | new GridInfoServerInConnector(m_Config, MainServer.Instance, "GridInfoService"); | ||
112 | } | ||
113 | |||
98 | } | 114 | } |
115 | |||
116 | #endregion | ||
117 | |||
99 | } | 118 | } |
100 | } | 119 | } |
diff --git a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs index 49dfd86..e73961b 100644 --- a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs | |||
@@ -36,8 +36,12 @@ using DotNetOpenId.Provider; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Server.Handlers.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using Nini.Config; | ||
42 | using OpenMetaverse; | ||
39 | 43 | ||
40 | namespace OpenSim.Grid.UserServer.Modules | 44 | namespace OpenSim.Server.Handlers.Authentication |
41 | { | 45 | { |
42 | /// <summary> | 46 | /// <summary> |
43 | /// Temporary, in-memory store for OpenID associations | 47 | /// Temporary, in-memory store for OpenID associations |
@@ -194,15 +198,17 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
194 | string m_contentType; | 198 | string m_contentType; |
195 | string m_httpMethod; | 199 | string m_httpMethod; |
196 | string m_path; | 200 | string m_path; |
197 | UserLoginService m_loginService; | 201 | IAuthenticationService m_authenticationService; |
202 | IUserAccountService m_userAccountService; | ||
198 | ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); | 203 | ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); |
199 | 204 | ||
200 | /// <summary> | 205 | /// <summary> |
201 | /// Constructor | 206 | /// Constructor |
202 | /// </summary> | 207 | /// </summary> |
203 | public OpenIdStreamHandler(string httpMethod, string path, UserLoginService loginService) | 208 | public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService) |
204 | { | 209 | { |
205 | m_loginService = loginService; | 210 | m_authenticationService = authService; |
211 | m_userAccountService = userService; | ||
206 | m_httpMethod = httpMethod; | 212 | m_httpMethod = httpMethod; |
207 | m_path = path; | 213 | m_path = path; |
208 | 214 | ||
@@ -235,13 +241,14 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
235 | IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; | 241 | IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; |
236 | string[] passwordValues = postQuery.GetValues("pass"); | 242 | string[] passwordValues = postQuery.GetValues("pass"); |
237 | 243 | ||
238 | UserProfileData profile; | 244 | UserAccount account; |
239 | if (TryGetProfile(new Uri(authRequest.ClaimedIdentifier.ToString()), out profile)) | 245 | if (TryGetAccount(new Uri(authRequest.ClaimedIdentifier.ToString()), out account)) |
240 | { | 246 | { |
241 | // Check for form POST data | 247 | // Check for form POST data |
242 | if (passwordValues != null && passwordValues.Length == 1) | 248 | if (passwordValues != null && passwordValues.Length == 1) |
243 | { | 249 | { |
244 | if (profile != null && m_loginService.AuthenticateUser(profile, passwordValues[0])) | 250 | if (account != null && |
251 | (m_authenticationService.Authenticate(account.PrincipalID, passwordValues[0], 30) != string.Empty)) | ||
245 | authRequest.IsAuthenticated = true; | 252 | authRequest.IsAuthenticated = true; |
246 | else | 253 | else |
247 | authRequest.IsAuthenticated = false; | 254 | authRequest.IsAuthenticated = false; |
@@ -250,7 +257,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
250 | { | 257 | { |
251 | // Authentication was requested, send the client a login form | 258 | // Authentication was requested, send the client a login form |
252 | using (StreamWriter writer = new StreamWriter(response)) | 259 | using (StreamWriter writer = new StreamWriter(response)) |
253 | writer.Write(String.Format(LOGIN_PAGE, profile.FirstName, profile.SurName)); | 260 | writer.Write(String.Format(LOGIN_PAGE, account.FirstName, account.LastName)); |
254 | return; | 261 | return; |
255 | } | 262 | } |
256 | } | 263 | } |
@@ -283,14 +290,14 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
283 | else | 290 | else |
284 | { | 291 | { |
285 | // Try and lookup this avatar | 292 | // Try and lookup this avatar |
286 | UserProfileData profile; | 293 | UserAccount account; |
287 | if (TryGetProfile(httpRequest.Url, out profile)) | 294 | if (TryGetAccount(httpRequest.Url, out account)) |
288 | { | 295 | { |
289 | using (StreamWriter writer = new StreamWriter(response)) | 296 | using (StreamWriter writer = new StreamWriter(response)) |
290 | { | 297 | { |
291 | // TODO: Print out a full profile page for this avatar | 298 | // TODO: Print out a full profile page for this avatar |
292 | writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, | 299 | writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, |
293 | httpRequest.Url.Authority, profile.FirstName, profile.SurName)); | 300 | httpRequest.Url.Authority, account.FirstName, account.LastName)); |
294 | } | 301 | } |
295 | } | 302 | } |
296 | else | 303 | else |
@@ -316,7 +323,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
316 | /// <param name="requestUrl">URL to parse for an avatar name</param> | 323 | /// <param name="requestUrl">URL to parse for an avatar name</param> |
317 | /// <param name="profile">Profile data for the avatar</param> | 324 | /// <param name="profile">Profile data for the avatar</param> |
318 | /// <returns>True if the parse and lookup were successful, otherwise false</returns> | 325 | /// <returns>True if the parse and lookup were successful, otherwise false</returns> |
319 | bool TryGetProfile(Uri requestUrl, out UserProfileData profile) | 326 | bool TryGetAccount(Uri requestUrl, out UserAccount account) |
320 | { | 327 | { |
321 | if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") | 328 | if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") |
322 | { | 329 | { |
@@ -326,12 +333,12 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
326 | 333 | ||
327 | if (name.Length == 2) | 334 | if (name.Length == 2) |
328 | { | 335 | { |
329 | profile = m_loginService.GetTheUser(name[0], name[1]); | 336 | account = m_userAccountService.GetUserAccount(UUID.Zero, name[0], name[1]); |
330 | return (profile != null); | 337 | return (account != null); |
331 | } | 338 | } |
332 | } | 339 | } |
333 | 340 | ||
334 | profile = null; | 341 | account = null; |
335 | return false; | 342 | return false; |
336 | } | 343 | } |
337 | } | 344 | } |