Annotation of /trunk/GridServer/LindenLogin.cs
Parent Directory
|
Revision Log
Revision 65 - (view) (download)
| 1 : | jhurliman | 65 | /* |
| 2 : | * Copyright (c) 2008 Intel Corporation | ||
| 3 : | * All rights reserved. | ||
| 4 : | * Redistribution and use in source and binary forms, with or without | ||
| 5 : | * modification, are permitted provided that the following conditions | ||
| 6 : | * are met: | ||
| 7 : | * | ||
| 8 : | * -- Redistributions of source code must retain the above copyright | ||
| 9 : | * notice, this list of conditions and the following disclaimer. | ||
| 10 : | * -- Redistributions in binary form must reproduce the above copyright | ||
| 11 : | * notice, this list of conditions and the following disclaimer in the | ||
| 12 : | * documentation and/or other materials provided with the distribution. | ||
| 13 : | * -- Neither the name of the Intel Corporation nor the names of its | ||
| 14 : | * contributors may be used to endorse or promote products derived from | ||
| 15 : | * this software without specific prior written permission. | ||
| 16 : | * | ||
| 17 : | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 18 : | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 19 : | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
| 20 : | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
| 21 : | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| 22 : | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 23 : | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| 24 : | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 25 : | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 26 : | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 27 : | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 28 : | */ | ||
| 29 : | |||
| 30 : | using System; | ||
| 31 : | using System.Collections; | ||
| 32 : | using Nwc.XmlRpc; | ||
| 33 : | using OpenMetaverse; | ||
| 34 : | using OpenMetaverse.StructuredData; | ||
| 35 : | |||
| 36 : | namespace GridServer | ||
| 37 : | { | ||
| 38 : | public class LindenLogin | ||
| 39 : | { | ||
| 40 : | #region Active parameters | ||
| 41 : | |||
| 42 : | /// <summary>True if login succeeded, otherwise false</summary> | ||
| 43 : | public bool Login; | ||
| 44 : | /// <summary>UUID of the agent logging in</summary> | ||
| 45 : | public UUID AgentID; | ||
| 46 : | /// <summary>Temporary session cookie that the client uses to authenticate requests</summary> | ||
| 47 : | public UUID SessionID; | ||
| 48 : | /// <summary>Temporary shared secret that is sent to the client at login and not transmitted | ||
| 49 : | /// over the wire again</summary> | ||
| 50 : | public UUID SecureSessionID; | ||
| 51 : | /// <summary>Agent first name</summary> | ||
| 52 : | public string FirstName; | ||
| 53 : | /// <summary>Agent last name</summary> | ||
| 54 : | public string LastName; | ||
| 55 : | /// <summary>Short string identifying the reason for login failure, such as 'key' | ||
| 56 : | /// for bad username or password</summary> | ||
| 57 : | public string ErrorReason; | ||
| 58 : | /// <summary>Welcome message, or longer description of the error reason</summary> | ||
| 59 : | public string Message; | ||
| 60 : | /// <summary>Starting simulator location. Either last, home, or a simulator name and position</summary> | ||
| 61 : | public string StartLocation; | ||
| 62 : | /// <summary>UDP port of the simulator being logged into</summary> | ||
| 63 : | public uint SimPort; | ||
| 64 : | /// <summary>IPv4 address of the simulator being logged into</summary> | ||
| 65 : | public string SimAddress; | ||
| 66 : | /// <summary>Circuit code to communicate with the simulator, used in the Linden UDP protocol</summary> | ||
| 67 : | public int CircuitCode; | ||
| 68 : | /// <summary>Grid X coordinate of the simulator being logged into</summary> | ||
| 69 : | public uint RegionX; | ||
| 70 : | /// <summary>Grid Y coordinate of the simulator being logged into</summary> | ||
| 71 : | public uint RegionY; | ||
| 72 : | /// <summary>Direction the avatar is looking upon login</summary> | ||
| 73 : | public Vector3 LookAt; | ||
| 74 : | /// <summary>Grid X coordinate of the home simulator</summary> | ||
| 75 : | public uint HomeRegionX; | ||
| 76 : | /// <summary>Grid Y coordinate of the home simulator</summary> | ||
| 77 : | public uint HomeRegionY; | ||
| 78 : | /// <summary>Home position</summary> | ||
| 79 : | public Vector3 HomePosition; | ||
| 80 : | /// <summary>Direction the avatar is looking when teleporting home</summary> | ||
| 81 : | public Vector3 HomeLookAt; | ||
| 82 : | /// <summary>Gender and inventory folder containing the avatar outfit to wear</summary> | ||
| 83 : | public Hashtable InitialOutfit; | ||
| 84 : | /// <summary>Root folder in the agent's inventory</summary> | ||
| 85 : | public UUID InventoryRoot; | ||
| 86 : | /// <summary>Folder list of the agent's inventory</summary> | ||
| 87 : | public ArrayList AgentInventory; | ||
| 88 : | /// <summary>Rot folder in the library inventory</summary> | ||
| 89 : | public UUID InventoryLibRoot; | ||
| 90 : | /// <summary>Folder list of the library inventory</summary> | ||
| 91 : | public ArrayList InventoryLibrary; | ||
| 92 : | /// <summary>List of active gesture inventory items</summary> | ||
| 93 : | public ArrayList ActiveGestures; | ||
| 94 : | /// <summary>Buddy list for this avatar</summary> | ||
| 95 : | public Hashtable BuddyList; | ||
| 96 : | /// <summary>Seed capability URL to request further capabilities from</summary> | ||
| 97 : | public string SeedCapability; | ||
| 98 : | |||
| 99 : | #endregion Active parameters | ||
| 100 : | |||
| 101 : | #region Automatic or unused parameters | ||
| 102 : | |||
| 103 : | /// <summary>Daylight savings time</summary> | ||
| 104 : | public string DST = (TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.UtcNow) ? "Y" : "N"); | ||
| 105 : | /// <summary>Owner of the library inventory</summary> | ||
| 106 : | public UUID InventoryLibraryOwner = UUID.Zero; | ||
| 107 : | /// <summary>Unused</summary> | ||
| 108 : | public ArrayList EventCategories = new ArrayList(); | ||
| 109 : | /// <summary>Unused</summary> | ||
| 110 : | public string StipendSinceLogin = "N"; | ||
| 111 : | /// <summary>Unused</summary> | ||
| 112 : | public string Gendered = "Y"; | ||
| 113 : | /// <summary>Unused</summary> | ||
| 114 : | public string EverLoggedIn = "Y"; | ||
| 115 : | /// <summary>Unused</summary> | ||
| 116 : | public string AgentAccess = "M"; | ||
| 117 : | /// <summary>Flag to tell the client whether to enable profile webpages or not</summary> | ||
| 118 : | public string AllowFirstLife = "Y"; | ||
| 119 : | /// <summary>Sun texture</summary> | ||
| 120 : | public UUID SunTexture = new UUID("cce0f112-878f-4586-a2e2-a8f104bba271"); | ||
| 121 : | /// <summary>Cloud texture</summary> | ||
| 122 : | public UUID CloudTexture = new UUID("dc4b9f0b-d008-45c6-96a4-01dd947ac621"); | ||
| 123 : | /// <summary>Moon texture</summary> | ||
| 124 : | public UUID MoonTexture = new UUID("ec4b9f0b-d008-45c6-96a4-01dd947ac621"); | ||
| 125 : | /// <summary>Categories for classified ads</summary> | ||
| 126 : | public ArrayList ClassifiedCategories = new ArrayList(); | ||
| 127 : | |||
| 128 : | #endregion Automatic or unused parameters | ||
| 129 : | |||
| 130 : | public LindenLogin() | ||
| 131 : | { | ||
| 132 : | } | ||
| 133 : | |||
| 134 : | public void AddClassifiedCategory(int id, string categoryName) | ||
| 135 : | { | ||
| 136 : | Hashtable hash = new Hashtable(2); | ||
| 137 : | hash["category_name"] = categoryName; | ||
| 138 : | hash["category_id"] = id; | ||
| 139 : | ClassifiedCategories.Add(hash); | ||
| 140 : | } | ||
| 141 : | |||
| 142 : | public void SetInitialOutfit(string folderName, bool male) | ||
| 143 : | { | ||
| 144 : | InitialOutfit["folder_name"] = folderName; | ||
| 145 : | InitialOutfit["gender"] = (male ? "male" : "female"); | ||
| 146 : | } | ||
| 147 : | |||
| 148 : | public virtual XmlRpcResponse ToXmlRpcResponse() | ||
| 149 : | { | ||
| 150 : | try | ||
| 151 : | { | ||
| 152 : | Hashtable responseData = new Hashtable(); | ||
| 153 : | |||
| 154 : | // Login flags | ||
| 155 : | Hashtable loginFlagsHash = new Hashtable(4); | ||
| 156 : | loginFlagsHash["daylight_savings"] = DST; | ||
| 157 : | loginFlagsHash["stipend_since_login"] = StipendSinceLogin; | ||
| 158 : | loginFlagsHash["gendered"] = Gendered; | ||
| 159 : | loginFlagsHash["ever_logged_in"] = EverLoggedIn; | ||
| 160 : | ArrayList loginFlags = new ArrayList(1); | ||
| 161 : | loginFlags.Add(loginFlagsHash); | ||
| 162 : | responseData["login-flags"] = loginFlags; | ||
| 163 : | |||
| 164 : | // Global textures | ||
| 165 : | Hashtable globalTexturesHash = new Hashtable(3); | ||
| 166 : | globalTexturesHash["sun_texture_id"] = SunTexture.ToString(); | ||
| 167 : | globalTexturesHash["cloud_texture_id"] = CloudTexture.ToString(); | ||
| 168 : | globalTexturesHash["moon_texture_id"] = MoonTexture.ToString(); | ||
| 169 : | ArrayList globalTextures = new ArrayList(1); | ||
| 170 : | globalTextures.Add(globalTexturesHash); | ||
| 171 : | responseData["global-textures"] = globalTextures; | ||
| 172 : | |||
| 173 : | // Event categories are unused | ||
| 174 : | ArrayList eventCategories = new ArrayList(1); | ||
| 175 : | Hashtable category = new Hashtable(2); | ||
| 176 : | category["category_name"] = "Defalt Event Category"; | ||
| 177 : | category["category_id"] = 20; | ||
| 178 : | eventCategories.Add(category); | ||
| 179 : | responseData["event_categories"] = eventCategories; | ||
| 180 : | |||
| 181 : | // Event notifications are unused | ||
| 182 : | responseData["event_notifications"] = new ArrayList(0); | ||
| 183 : | |||
| 184 : | // UI Config | ||
| 185 : | Hashtable uiConfigHash = new Hashtable(1); | ||
| 186 : | uiConfigHash["allow_first_life"] = AllowFirstLife; | ||
| 187 : | ArrayList uiConfig = new ArrayList(1); | ||
| 188 : | uiConfig.Add(uiConfigHash); | ||
| 189 : | responseData["ui-config"] = uiConfig; | ||
| 190 : | |||
| 191 : | // Home | ||
| 192 : | System.Text.StringBuilder homeString = new System.Text.StringBuilder("{'region_handle':[r"); | ||
| 193 : | homeString.Append(256 * HomeRegionX); | ||
| 194 : | homeString.Append(",r"); | ||
| 195 : | homeString.Append(256 * HomeRegionY); | ||
| 196 : | homeString.Append("], 'position':[r"); | ||
| 197 : | homeString.Append(HomePosition.X); | ||
| 198 : | homeString.Append(",r"); | ||
| 199 : | homeString.Append(HomePosition.Y); | ||
| 200 : | homeString.Append(",r"); | ||
| 201 : | homeString.Append(HomePosition.Z); | ||
| 202 : | homeString.Append("], 'look_at':[r"); | ||
| 203 : | homeString.Append(HomeLookAt.X); | ||
| 204 : | homeString.Append(",r"); | ||
| 205 : | homeString.Append(HomeLookAt.Y); | ||
| 206 : | homeString.Append(",r"); | ||
| 207 : | homeString.Append(HomeLookAt.Z); | ||
| 208 : | homeString.Append("]}"); | ||
| 209 : | //responseData["home"] = String.Format("{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}", | ||
| 210 : | // 256 * HomeRegionX, 256 * HomeRegionY, HomePosition.X, HomePosition.Y, HomePosition.Z, HomeLookAt.X, HomeLookAt.Y, HomeLookAt.Z); | ||
| 211 : | responseData["home"] = homeString.ToString(); | ||
| 212 : | |||
| 213 : | // LookAt | ||
| 214 : | responseData["look_at"] = String.Format("[r{0},r{1},r{2}]", LookAt.X, LookAt.Y, LookAt.Z); | ||
| 215 : | |||
| 216 : | // Inventory root | ||
| 217 : | Hashtable inventoryRootHash = new Hashtable(1); | ||
| 218 : | inventoryRootHash["folder_id"] = InventoryRoot.ToString(); | ||
| 219 : | ArrayList inventoryRoot = new ArrayList(1); | ||
| 220 : | inventoryRoot.Add(inventoryRootHash); | ||
| 221 : | responseData["inventory-root"] = inventoryRoot; | ||
| 222 : | |||
| 223 : | // Inventory library root | ||
| 224 : | Hashtable inventoryLibRootHash = new Hashtable(1); | ||
| 225 : | inventoryLibRootHash["folder_id"] = InventoryLibRoot.ToString(); | ||
| 226 : | ArrayList inventoryLibRoot = new ArrayList(1); | ||
| 227 : | inventoryLibRoot.Add(inventoryLibRootHash); | ||
| 228 : | responseData["inventory-lib-root"] = inventoryLibRoot; | ||
| 229 : | |||
| 230 : | // Inventory skeletons | ||
| 231 : | responseData["inventory-skeleton"] = AgentInventory; | ||
| 232 : | responseData["inventory-skel-lib"] = InventoryLibrary; | ||
| 233 : | |||
| 234 : | // | ||
| 235 : | responseData["login"] = Login.ToString().ToLower(); | ||
| 236 : | responseData["first_name"] = FirstName; | ||
| 237 : | responseData["last_name"] = LastName; | ||
| 238 : | responseData["agent_access"] = AgentAccess; | ||
| 239 : | responseData["sim_port"] = (int)SimPort; | ||
| 240 : | responseData["sim_ip"] = SimAddress; | ||
| 241 : | responseData["agent_id"] = AgentID.ToString(); | ||
| 242 : | responseData["session_id"] = SessionID.ToString(); | ||
| 243 : | responseData["secure_session_id"] = SecureSessionID.ToString(); | ||
| 244 : | responseData["circuit_code"] = CircuitCode; | ||
| 245 : | responseData["seconds_since_epoch"] = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
| 246 : | responseData["seed_capability"] = SeedCapability; | ||
| 247 : | responseData["classified_categories"] = ClassifiedCategories; | ||
| 248 : | responseData["gestures"] = ActiveGestures; | ||
| 249 : | responseData["inventory-lib-owner"] = InventoryLibraryOwner.ToString(); | ||
| 250 : | |||
| 251 : | if (InitialOutfit != null) | ||
| 252 : | responseData["initial-outfit"] = InitialOutfit; | ||
| 253 : | else | ||
| 254 : | responseData["initial-outfit"] = new ArrayList(0); | ||
| 255 : | |||
| 256 : | responseData["start_location"] = StartLocation; | ||
| 257 : | responseData["seed_capability"] = SeedCapability; | ||
| 258 : | responseData["message"] = Message; | ||
| 259 : | responseData["reason"] = String.Empty; | ||
| 260 : | |||
| 261 : | responseData["region_x"] = (int)(RegionX * 256); | ||
| 262 : | responseData["region_y"] = (int)(RegionY * 256); | ||
| 263 : | |||
| 264 : | ArrayList buddyList = new ArrayList(); | ||
| 265 : | if (BuddyList != null) | ||
| 266 : | buddyList.Add(BuddyList); | ||
| 267 : | responseData["buddy-list"] = buddyList; | ||
| 268 : | |||
| 269 : | XmlRpcResponse response = new XmlRpcResponse(); | ||
| 270 : | response.Value = responseData; | ||
| 271 : | return response; | ||
| 272 : | } | ||
| 273 : | catch (Exception ex) | ||
| 274 : | { | ||
| 275 : | Logger.Log.Error("Error creating XML-RPC login response: " + ex.Message, ex); | ||
| 276 : | return GenerateFailureResponse("Internal Error", "Error generating login response", false); | ||
| 277 : | } | ||
| 278 : | } | ||
| 279 : | |||
| 280 : | //public OSD ToLLSDResponse() | ||
| 281 : | //{ | ||
| 282 : | // try | ||
| 283 : | // { | ||
| 284 : | // OSDMap map = new OSDMap(); | ||
| 285 : | |||
| 286 : | // map["first_name"] = OSD.FromString(Firstname); | ||
| 287 : | // map["last_name"] = OSD.FromString(Lastname); | ||
| 288 : | // map["agent_access"] = OSD.FromString(agentAccess); | ||
| 289 : | |||
| 290 : | // map["sim_port"] = OSD.FromInteger(SimPort); | ||
| 291 : | // map["sim_ip"] = OSD.FromString(SimAddress); | ||
| 292 : | |||
| 293 : | // map["agent_id"] = OSD.FromUUID(AgentID); | ||
| 294 : | // map["session_id"] = OSD.FromUUID(SessionID); | ||
| 295 : | // map["secure_session_id"] = OSD.FromUUID(SecureSessionID); | ||
| 296 : | // map["circuit_code"] = OSD.FromInteger(CircuitCode); | ||
| 297 : | // map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); | ||
| 298 : | |||
| 299 : | // #region Login Flags | ||
| 300 : | |||
| 301 : | // OSDMap loginFlagsLLSD = new OSDMap(); | ||
| 302 : | // loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); | ||
| 303 : | // loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); | ||
| 304 : | // loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); | ||
| 305 : | // loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); | ||
| 306 : | // map["login-flags"] = WrapOSDMap(loginFlagsLLSD); | ||
| 307 : | |||
| 308 : | // #endregion Login Flags | ||
| 309 : | |||
| 310 : | // #region Global Textures | ||
| 311 : | |||
| 312 : | // OSDMap globalTexturesLLSD = new OSDMap(); | ||
| 313 : | // globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); | ||
| 314 : | // globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); | ||
| 315 : | // globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); | ||
| 316 : | |||
| 317 : | // map["global-textures"] = WrapOSDMap(globalTexturesLLSD); | ||
| 318 : | |||
| 319 : | // #endregion Global Textures | ||
| 320 : | |||
| 321 : | // map["seed_capability"] = OSD.FromString(seedCapability); | ||
| 322 : | |||
| 323 : | // map["event_categories"] = ArrayListToOSDArray(eventCategories); | ||
| 324 : | // //map["event_notifications"] = new OSDArray(); // todo | ||
| 325 : | // map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); | ||
| 326 : | |||
| 327 : | // #region UI Config | ||
| 328 : | |||
| 329 : | // OSDMap uiConfigLLSD = new OSDMap(); | ||
| 330 : | // uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); | ||
| 331 : | // map["ui-config"] = WrapOSDMap(uiConfigLLSD); | ||
| 332 : | |||
| 333 : | // #endregion UI Config | ||
| 334 : | |||
| 335 : | // #region Inventory | ||
| 336 : | |||
| 337 : | // map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); | ||
| 338 : | |||
| 339 : | // map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); | ||
| 340 : | // map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; | ||
| 341 : | // map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); | ||
| 342 : | // map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); | ||
| 343 : | |||
| 344 : | // #endregion Inventory | ||
| 345 : | |||
| 346 : | // map["gestures"] = ArrayListToOSDArray(activeGestures); | ||
| 347 : | |||
| 348 : | // map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); | ||
| 349 : | // map["start_location"] = OSD.FromString(startLocation); | ||
| 350 : | |||
| 351 : | // map["seed_capability"] = OSD.FromString(seedCapability); | ||
| 352 : | // map["home"] = OSD.FromString(home); | ||
| 353 : | // map["look_at"] = OSD.FromString(lookAt); | ||
| 354 : | // map["message"] = OSD.FromString(welcomeMessage); | ||
| 355 : | // map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); | ||
| 356 : | // map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); | ||
| 357 : | |||
| 358 : | // if (m_buddyList != null) | ||
| 359 : | // { | ||
| 360 : | // map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); | ||
| 361 : | // } | ||
| 362 : | |||
| 363 : | // map["login"] = OSD.FromString("true"); | ||
| 364 : | |||
| 365 : | // return map; | ||
| 366 : | // } | ||
| 367 : | // catch (Exception e) | ||
| 368 : | // { | ||
| 369 : | // m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | ||
| 370 : | |||
| 371 : | // return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); | ||
| 372 : | // } | ||
| 373 : | //} | ||
| 374 : | |||
| 375 : | public XmlRpcResponse GenerateFailureResponse(string reason, string message, bool loginSuccess) | ||
| 376 : | { | ||
| 377 : | Hashtable loginError = new Hashtable(3); | ||
| 378 : | loginError["reason"] = reason; | ||
| 379 : | loginError["message"] = message; | ||
| 380 : | loginError["login"] = loginSuccess.ToString().ToLower(); | ||
| 381 : | |||
| 382 : | XmlRpcResponse response = new XmlRpcResponse(); | ||
| 383 : | response.Value = loginError; | ||
| 384 : | return response; | ||
| 385 : | } | ||
| 386 : | } | ||
| 387 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

