From e7bcf1e9ec8014f30ba68dc4323517021d882ac0 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 30 Mar 2012 09:51:30 -0500 Subject: [PATCH] Modified LLUserAuth to use LLSD when parsing login response parameters. Will facilitate easy wholesale replacement with LLLoginInstance in the future. --- indra/newview/llclassifiedinfo.cpp | 72 +- indra/newview/llclassifiedinfo.h | 39 +- indra/newview/lleventinfo.cpp | 36 +- indra/newview/lleventinfo.h | 2 +- indra/newview/lleventnotifier.cpp | 81 ++- indra/newview/lleventnotifier.h | 4 +- indra/newview/llstartup.cpp | 901 +++++++++++++------------- indra/newview/lluserauth.cpp | 183 +++--- indra/newview/lluserauth.h | 14 +- indra/newview/llviewertextureanim.cpp | 36 +- indra/newview/llviewertextureanim.h | 36 +- 11 files changed, 656 insertions(+), 748 deletions(-) diff --git a/indra/newview/llclassifiedinfo.cpp b/indra/newview/llclassifiedinfo.cpp index 5cf1579d0..800aff149 100644 --- a/indra/newview/llclassifiedinfo.cpp +++ b/indra/newview/llclassifiedinfo.cpp @@ -2,31 +2,25 @@ * @file llclassifiedinfo.cpp * @brief LLClassifiedInfo class definition * - * $LicenseInfo:firstyear=2005&license=viewergpl$ - * - * Copyright (c) 2005-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -38,35 +32,19 @@ LLClassifiedInfo::cat_map LLClassifiedInfo::sCategories; // static -void LLClassifiedInfo::loadCategories(LLUserAuth::options_t classified_options) +void LLClassifiedInfo::loadCategories(const LLSD& options) { - LLUserAuth::options_t::iterator resp_it; - for (resp_it = classified_options.begin(); - resp_it != classified_options.end(); - ++resp_it) + for(LLSD::array_const_iterator resp_it = options.beginArray(), + end = options.endArray(); resp_it != end; ++resp_it) { - const LLUserAuth::response_t& response = *resp_it; - - LLUserAuth::response_t::const_iterator option_it; - - S32 cat_id = 0; - option_it = response.find("category_id"); - if (option_it != response.end()) + LLSD name = (*resp_it)["category_name"]; + if(name.isDefined()) { - cat_id = atoi(option_it->second.c_str()); + LLSD id = (*resp_it)["category_id"]; + if(id.isDefined()) + { + LLClassifiedInfo::sCategories[id.asInteger()] = name.asString(); + } } - else - { - continue; - } - - // Add the category id/name pair - option_it = response.find("category_name"); - if (option_it != response.end()) - { - LLClassifiedInfo::sCategories[cat_id] = option_it->second; - } - } - } diff --git a/indra/newview/llclassifiedinfo.h b/indra/newview/llclassifiedinfo.h index cc5a6bf28..3ff793b16 100644 --- a/indra/newview/llclassifiedinfo.h +++ b/indra/newview/llclassifiedinfo.h @@ -2,31 +2,25 @@ * @file llclassifiedinfo.h * @brief LLClassifiedInfo class definition * - * $LicenseInfo:firstyear=2005&license=viewergpl$ - * - * Copyright (c) 2005-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -37,7 +31,6 @@ #include "v3dmath.h" #include "lluuid.h" -#include "lluserauth.h" class LLMessageSystem; @@ -46,7 +39,7 @@ class LLClassifiedInfo public: LLClassifiedInfo() {} - static void loadCategories(LLUserAuth::options_t event_options); + static void loadCategories(const LLSD& options); typedef std::map cat_map; static cat_map sCategories; diff --git a/indra/newview/lleventinfo.cpp b/indra/newview/lleventinfo.cpp index c0974040b..f35433941 100644 --- a/indra/newview/lleventinfo.cpp +++ b/indra/newview/lleventinfo.cpp @@ -101,35 +101,19 @@ void LLEventInfo::unpack(LLMessageSystem *msg) } // static -void LLEventInfo::loadCategories(LLUserAuth::options_t event_options) +void LLEventInfo::loadCategories(LLSD& event_options) { - LLUserAuth::options_t::iterator resp_it; - for (resp_it = event_options.begin(); - resp_it != event_options.end(); - ++resp_it) + for(LLSD::array_const_iterator resp_it = event_options.beginArray(), + end = event_options.endArray(); resp_it != end; ++resp_it) { - const LLUserAuth::response_t& response = *resp_it; - - LLUserAuth::response_t::const_iterator option_it; - - S32 cat_id = 0; - option_it = response.find("category_id"); - if (option_it != response.end()) + LLSD name = (*resp_it)["category_name"]; + if(name.isDefined()) { - cat_id = atoi(option_it->second.c_str()); + LLSD id = (*resp_it)["category_id"]; + if(id.isDefined()) + { + LLEventInfo::sCategories[id.asInteger()] = name.asString(); + } } - else - { - continue; - } - - // Add the category id/name pair - option_it = response.find("category_name"); - if (option_it != response.end()) - { - LLEventInfo::sCategories[cat_id] = option_it->second; - } - } - } diff --git a/indra/newview/lleventinfo.h b/indra/newview/lleventinfo.h index 880517a9f..2da168eba 100644 --- a/indra/newview/lleventinfo.h +++ b/indra/newview/lleventinfo.h @@ -48,7 +48,7 @@ public: void unpack(LLMessageSystem *msg); - static void loadCategories(LLUserAuth::options_t event_options); + static void loadCategories(LLSD& event_options); public: std::string mName; diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp index 20422369d..4cbbbc420 100644 --- a/indra/newview/lleventnotifier.cpp +++ b/indra/newview/lleventnotifier.cpp @@ -115,15 +115,12 @@ bool LLEventNotifier::handleResponse(U32 eventId, LLVector3d eventPos, const LLS return true; } -void LLEventNotifier::load(const LLUserAuth::options_t& event_options) +void LLEventNotifier::load(const LLSD& event_options) { - LLUserAuth::options_t::const_iterator resp_it; - for (resp_it = event_options.begin(); - resp_it != event_options.end(); - ++resp_it) + for(LLSD::array_const_iterator resp_it = event_options.beginArray(), + end = event_options.endArray(); resp_it != end; ++resp_it) { - const LLUserAuth::response_t& response = *resp_it; - + LLSD response = *resp_it; LLEventNotification *new_enp = new LLEventNotification(); if (!new_enp->load(response)) @@ -134,6 +131,7 @@ void LLEventNotifier::load(const LLUserAuth::options_t& event_options) mEventNotifications[new_enp->getEventID()] = new_enp; } + } void LLEventNotifier::add(U32 eventId) @@ -216,48 +214,47 @@ LLEventNotification::~LLEventNotification() } -BOOL LLEventNotification::load(const LLUserAuth::response_t &response) +BOOL LLEventNotification::load(const LLSD& response) { - - LLUserAuth::response_t::const_iterator option_it; BOOL event_ok = TRUE; - option_it = response.find("event_id"); - if (option_it != response.end()) + LLSD event_id = response["event_id"]; + if (event_id.isDefined()) { - mEventID = atoi(option_it->second.c_str()); + mEventID = event_id.asInteger(); } else { event_ok = FALSE; } - option_it = response.find("event_name"); - if (option_it != response.end()) + LLSD event_name = response["event_name"]; + if (event_name.isDefined()) { - llinfos << "Event: " << option_it->second << llendl; - mEventName = option_it->second; + mEventName = event_name.asString(); + llinfos << "Event: " << mEventName << llendl; } else { event_ok = FALSE; } /* - option_it = response.find("event_date"); - if (option_it != response.end()) + LLSD event_date = response["event_date"]; + if (event_date.isDefined()) { - llinfos << "EventDate: " << option_it->second << llendl; - mEventDateStr = option_it->second; + mEventDate = event_date.asString(); + llinfos << "EventDate: " << mEventDate << llendl; } else { event_ok = FALSE; } */ - option_it = response.find("event_date_ut"); - if (option_it != response.end()) + LLSD event_date_ut = response["event_date_ut"]; + if (event_date_ut.isDefined()) { - llinfos << "EventDate: " << option_it->second << llendl; - mEventDate = strtoul(option_it->second.c_str(), NULL, 10); + std::string date = event_date_ut.asString(); + llinfos << "EventDate: " << date << llendl; + mEventDate = strtoul(date.c_str(), NULL, 10); // Convert to Pacific, based on server's opinion of whether // it's daylight savings time there. @@ -282,44 +279,44 @@ BOOL LLEventNotification::load(const LLUserAuth::response_t &response) S32 x_region = 0; S32 y_region = 0; - option_it = response.find("grid_x"); - if (option_it != response.end()) + LLSD grid_x_sd = response["grid_x"]; + if (grid_x_sd.isDefined()) { - llinfos << "GridX: " << option_it->second << llendl; - grid_x= atoi(option_it->second.c_str()); + grid_x= grid_x_sd.asInteger(); + llinfos << "GridX: " << grid_x << llendl; } else { event_ok = FALSE; } - option_it = response.find("grid_y"); - if (option_it != response.end()) + LLSD grid_y_sd = response["grid_y"]; + if (grid_y_sd.isDefined()) { - llinfos << "GridY: " << option_it->second << llendl; - grid_y = atoi(option_it->second.c_str()); + grid_y= grid_y_sd.asInteger(); + llinfos << "GridY: " << grid_y << llendl; } else { event_ok = FALSE; } - option_it = response.find("x_region"); - if (option_it != response.end()) - { - llinfos << "RegionX: " << option_it->second << llendl; - x_region = atoi(option_it->second.c_str()); + LLSD x_region_sd = response["x_region"]; + if (x_region_sd.isDefined()) + { + x_region = x_region_sd.asInteger(); + llinfos << "RegionX: " << x_region << llendl; } else { event_ok = FALSE; } - option_it = response.find("y_region"); - if (option_it != response.end()) + LLSD y_region_sd = response["y_region"]; + if (y_region_sd.isDefined()) { - llinfos << "RegionY: " << option_it->second << llendl; - y_region = atoi(option_it->second.c_str()); + y_region = y_region_sd.asInteger(); + llinfos << "RegionY: " << y_region << llendl; } else { diff --git a/indra/newview/lleventnotifier.h b/indra/newview/lleventnotifier.h index f5e03a3fb..efb59b815 100644 --- a/indra/newview/lleventnotifier.h +++ b/indra/newview/lleventnotifier.h @@ -52,7 +52,7 @@ public: void add(LLEventInfo &event_info); // Add a new notification for an event void add(U32 eventId); - void load(const LLUserAuth::options_t& event_options); // In the format that it comes in from LLUserAuth + void load(const LLSD& event_options); // In the format that it comes in from login void remove(U32 event_id); BOOL hasNotification(const U32 event_id); @@ -73,7 +73,7 @@ public: LLEventNotification(); virtual ~LLEventNotification(); - BOOL load(const LLUserAuth::response_t &en); // In the format it comes in from LLUserAuth + BOOL load(const LLSD& en); // In the format it comes in from LLUserAuth BOOL load(const LLEventInfo &event_info); // From existing event_info on the viewer. //void setEventID(const U32 event_id); //void setEventName(std::string &event_name); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 4cf6f3ac0..4af5db51e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -271,6 +271,8 @@ EStartupState LLStartUp::gStartupState = STATE_FIRST; static U64 gFirstSimHandle = 0; static LLHost gFirstSim; static std::string gFirstSimSeedCap; +static LLVector3 gAgentStartLookAt(1.0f, 0.f, 0.f); +static std::string gAgentStartLocation = "safe"; // // local function declaration // @@ -293,6 +295,7 @@ void init_start_screen(S32 location_id); void release_start_screen(); void reset_login(); void apply_udp_blacklist(const std::string& csv); +bool process_login_success_response(std::string &password); void callback_cache_name(const LLUUID& id, const std::string& full_name, bool is_group) { @@ -384,8 +387,6 @@ bool idle_startup() static LLVector3 initial_sun_direction(1.f, 0.f, 0.f); static LLVector3 agent_start_position_region(10.f, 10.f, 10.f); // default for when no space server - static LLVector3 agent_start_look_at(1.0f, 0.f, 0.f); - static std::string agent_start_location = "safe"; // last location by default static S32 agent_location_id = START_LOCATION_ID_LAST; @@ -393,8 +394,6 @@ bool idle_startup() static bool show_connect_box = true; - static bool stipend_since_login = false; - static bool samename = false; // HACK: These are things from the main loop that usually aren't done @@ -1432,18 +1431,26 @@ bool idle_startup() std::ostringstream emsg; bool quit = false; bool update = false; - std::string login_response; - std::string reason_response; - std::string message_response; bool successful_login = false; LLUserAuth::UserAuthcode error = LLUserAuth::getInstance()->authResponse(); // reset globals gAcceptTOS = FALSE; gAcceptCriticalMessage = FALSE; + std::string login_response; + std::string reason_response; + std::string message_response; + std::string message_id; + LLSD response; + switch(error) { case LLUserAuth::E_OK: - login_response = LLUserAuth::getInstance()->getResponse("login"); + response = LLUserAuth::getInstance()->getResponse(); + login_response = response["login"]; + reason_response = response["reason"]; + message_response = response["message"]; + message_id = response["message_id"]; + if(login_response == "true") { // Yay, login! @@ -1452,8 +1459,6 @@ bool idle_startup() else { emsg << LLTrans::getString("LoginFailed") + "\n"; - reason_response = LLUserAuth::getInstance()->getResponse("reason"); - message_response = LLUserAuth::getInstance()->getResponse("message"); if (!message_response.empty()) { @@ -1512,13 +1517,13 @@ bool idle_startup() } if(reason_response == "update") { - auth_message = LLUserAuth::getInstance()->getResponse("message"); + auth_message = message_response; update = true; } if(reason_response == "optional") { LL_DEBUGS("AppInit") << "Login got optional update" << LL_ENDL; - auth_message = LLUserAuth::getInstance()->getResponse("message"); + auth_message = message_response; if (show_connect_box) { update_app(FALSE, auth_message); @@ -1572,321 +1577,8 @@ bool idle_startup() // XML-RPC successful login path here if (successful_login) { - std::string text; - text = LLUserAuth::getInstance()->getResponse("udp_blacklist"); - if(!text.empty()) - { - apply_udp_blacklist(text); - } - // unpack login data needed by the application - text = LLUserAuth::getInstance()->getResponse("agent_id"); - if(!text.empty()) gAgentID.set(text); - gDebugInfo["AgentID"] = text; - - text = LLUserAuth::getInstance()->getResponse("session_id"); - if(!text.empty()) gAgentSessionID.set(text); - gDebugInfo["SessionID"] = text; - - text = LLUserAuth::getInstance()->getResponse("secure_session_id"); - if(!text.empty()) gAgent.mSecureSessionID.set(text); - - text = LLUserAuth::getInstance()->getResponse("first_name"); - if(!text.empty()) - { - // Remove quotes from string. Login.cgi sends these to force - // names that look like numbers into strings. - firstname.assign(text); - LLStringUtil::replaceChar(firstname, '"', ' '); - LLStringUtil::trim(firstname); - } - text = LLUserAuth::getInstance()->getResponse("last_name"); - if(!text.empty()) lastname.assign(text); - gSavedSettings.setString("FirstName", firstname); - gSavedSettings.setString("LastName", lastname); - // - gFullName = utf8str_tolower(firstname + " " + lastname); - // - - if (gSavedSettings.getBOOL("RememberPassword")) - { - // Successful login means the password is valid, so save it. - LLStartUp::savePasswordToDisk(password); - } - else - { - // Don't leave password from previous session sitting around - // during this login session. - LLStartUp::deletePasswordFromDisk(); - password.assign(""); // clear the password so it isn't saved to login history either - } - - { - // Save the login history data to disk - std::string history_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "saved_logins_sg2.xml"); - - LLSavedLogins history_data = LLSavedLogins::loadFile(history_file); - std::string grid_nick = gHippoGridManager->getConnectedGrid()->getGridName(); - history_data.deleteEntry(firstname, lastname, grid_nick); - if (gSavedSettings.getBOOL("RememberLogin")) - { - LLSavedLoginEntry login_entry(firstname, lastname, password, grid_nick); - history_data.addEntry(login_entry); - } - else - { - // Clear the old-style login data as well - gSavedSettings.setString("FirstName", std::string("")); - gSavedSettings.setString("LastName", std::string("")); - } - - LLSavedLogins::saveFile(history_data, history_file); - } - - // this is their actual ability to access content - text = LLUserAuth::getInstance()->getResponse("agent_access_max"); - if (!text.empty()) - { - // agent_access can be 'A', 'M', and 'PG'. - gAgent.setMaturity(text[0]); - } - - // this is the value of their preference setting for that content - // which will always be <= agent_access_max - text = LLUserAuth::getInstance()->getResponse("agent_region_access"); - if (!text.empty()) - { - int preferredMaturity = LLAgent::convertTextToMaturity(text[0]); - gSavedSettings.setU32("PreferredMaturity", preferredMaturity); - } - // During the AO transition, this flag will be true. Then the flag will - // go away. After the AO transition, this code and all the code that - // uses it can be deleted. - text = LLUserAuth::getInstance()->getResponse("ao_transition"); - if (!text.empty()) - { - if (text == "1") - { - gAgent.setAOTransition(); - } - } - - text = LLUserAuth::getInstance()->getResponse("start_location"); - if(!text.empty()) agent_start_location.assign(text); - text = LLUserAuth::getInstance()->getResponse("circuit_code"); - if(!text.empty()) - { - gMessageSystem->mOurCircuitCode = strtoul(text.c_str(), NULL, 10); - } - std::string sim_ip_str = LLUserAuth::getInstance()->getResponse("sim_ip"); - std::string sim_port_str = LLUserAuth::getInstance()->getResponse("sim_port"); - if(!sim_ip_str.empty() && !sim_port_str.empty()) - { - U32 sim_port = strtoul(sim_port_str.c_str(), NULL, 10); - gFirstSim.set(sim_ip_str, sim_port); - if (gFirstSim.isOk()) - { - gMessageSystem->enableCircuit(gFirstSim, TRUE); - } - } - std::string region_x_str = LLUserAuth::getInstance()->getResponse("region_x"); - std::string region_y_str = LLUserAuth::getInstance()->getResponse("region_y"); - if(!region_x_str.empty() && !region_y_str.empty()) - { - U32 region_x = strtoul(region_x_str.c_str(), NULL, 10); - U32 region_y = strtoul(region_y_str.c_str(), NULL, 10); - gFirstSimHandle = to_region_handle(region_x, region_y); - } - - const std::string look_at_str = LLUserAuth::getInstance()->getResponse("look_at"); - if (!look_at_str.empty()) - { - size_t len = look_at_str.size(); - LLMemoryStream mstr((U8*)look_at_str.c_str(), len); - LLSD sd = LLSDSerialize::fromNotation(mstr, len); - agent_start_look_at = ll_vector3_from_sd(sd); - } - - text = LLUserAuth::getInstance()->getResponse("seed_capability"); - if (!text.empty()) gFirstSimSeedCap = text; - - text = LLUserAuth::getInstance()->getResponse("seconds_since_epoch"); - if(!text.empty()) - { - U32 server_utc_time = strtoul(text.c_str(), NULL, 10); - if(server_utc_time) - { - time_t now = time(NULL); - gUTCOffset = (server_utc_time - now); - } - } - - std::string home_location = LLUserAuth::getInstance()->getResponse("home"); - if(!home_location.empty()) - { - size_t len = home_location.size(); - LLMemoryStream mstr((U8*)home_location.c_str(), len); - LLSD sd = LLSDSerialize::fromNotation(mstr, len); - S32 region_x = sd["region_handle"][0].asInteger(); - S32 region_y = sd["region_handle"][1].asInteger(); - U64 region_handle = to_region_handle(region_x, region_y); - LLVector3 position = ll_vector3_from_sd(sd["position"]); - gAgent.setHomePosRegion(region_handle, position); - } - - gAgent.mMOTD.assign(LLUserAuth::getInstance()->getResponse("message")); - LLUserAuth::options_t options; - if(LLUserAuth::getInstance()->getOptions("inventory-root", options)) - { - LLUserAuth::response_t::iterator it; - it = options[0].find("folder_id"); - if(it != options[0].end()) - { - gInventory.setRootFolderID(LLUUID((*it).second)); - //gInventory.mock(gInventory.getRootFolderID()); - } - } - - options.clear(); - if(LLUserAuth::getInstance()->getOptions("login-flags", options)) - { - LLUserAuth::response_t::iterator it; - LLUserAuth::response_t::iterator no_flag = options[0].end(); - it = options[0].find("ever_logged_in"); - if(it != no_flag) - { - if((*it).second == "N") gAgent.setFirstLogin(TRUE); - else gAgent.setFirstLogin(FALSE); - } - it = options[0].find("stipend_since_login"); - if(it != no_flag) - { - if((*it).second == "Y") stipend_since_login = true; - } - it = options[0].find("gendered"); - if(it != no_flag) - { - if((*it).second == "Y") gAgent.setGenderChosen(TRUE); - } - it = options[0].find("daylight_savings"); - if(it != no_flag) - { - if((*it).second == "Y") gPacificDaylightTime = TRUE; - else gPacificDaylightTime = FALSE; - } - } - options.clear(); - if (LLUserAuth::getInstance()->getOptions("initial-outfit", options) - && !options.empty()) - { - LLUserAuth::response_t::iterator it; - LLUserAuth::response_t::iterator it_end = options[0].end(); - it = options[0].find("folder_name"); - if(it != it_end) - { - // Initial outfit is a folder in your inventory, - // must be an exact folder-name match. - sInitialOutfit = (*it).second; - } - it = options[0].find("gender"); - if (it != it_end) - { - sInitialOutfitGender = (*it).second; - } - } - - options.clear(); - if(LLUserAuth::getInstance()->getOptions("global-textures", options)) - { - // Extract sun and moon texture IDs. These are used - // in the LLVOSky constructor, but I can't figure out - // how to pass them in. JC - LLUserAuth::response_t::iterator it; - LLUserAuth::response_t::iterator no_texture = options[0].end(); - it = options[0].find("sun_texture_id"); - if(it != no_texture) - { - gSunTextureID.set((*it).second); - } - it = options[0].find("moon_texture_id"); - if(it != no_texture) - { - gMoonTextureID.set((*it).second); - } - it = options[0].find("cloud_texture_id"); - if(it != no_texture) - { - gCloudTextureID.set((*it).second); - } - } - - std::string map_server_url = LLUserAuth::getInstance()->getResponse("map-server-url"); - if(!map_server_url.empty()) - { - gSavedSettings.setString("MapServerURL", map_server_url); - LLWorldMap::gotMapServerURL(true); - } - - // Override grid info with anything sent in the login response - std::string tmp = LLUserAuth::getInstance()->getResponse("gridname"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setGridName(tmp); - tmp = LLUserAuth::getInstance()->getResponse("loginuri"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginUri(tmp); - tmp = LLUserAuth::getInstance()->getResponse("welcome"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginPage(tmp); - tmp = LLUserAuth::getInstance()->getResponse("loginpage"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginPage(tmp); - tmp = LLUserAuth::getInstance()->getResponse("economy"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setHelperUri(tmp); - tmp = LLUserAuth::getInstance()->getResponse("helperuri"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setHelperUri(tmp); - tmp = LLUserAuth::getInstance()->getResponse("about"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setWebSite(tmp); - tmp = LLUserAuth::getInstance()->getResponse("website"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setWebSite(tmp); - tmp = LLUserAuth::getInstance()->getResponse("help"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSupportUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("support"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSupportUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("register"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRegisterUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("account"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRegisterUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("password"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setPasswordUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("search"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSearchUrl(tmp); - tmp = LLUserAuth::getInstance()->getResponse("currency"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setCurrencySymbol(tmp); - tmp = LLUserAuth::getInstance()->getResponse("real_currency"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRealCurrencySymbol(tmp); - tmp = LLUserAuth::getInstance()->getResponse("directory_fee"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setDirectoryFee(atoi(tmp.c_str())); - tmp = LLUserAuth::getInstance()->getResponse("max_groups"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setMaxAgentGroups(atoi(tmp.c_str())); - tmp = LLUserAuth::getInstance()->getResponse("max-agent-groups"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setMaxAgentGroups(atoi(tmp.c_str())); - tmp = LLUserAuth::getInstance()->getResponse("VoiceConnector"); - if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setVoiceConnector(tmp); - gHippoGridManager->saveFile(); - gHippoLimits->setLimits(); - - } - - // OGPX : successful login path common to OGP and XML-RPC - if (successful_login) - { - gIMMgr->loadIgnoreGroup(); - - // JC: gesture loading done below, when we have an asset system - // in place. Don't delete/clear user_credentials until then. - - if(gAgentID.notNull() - && gAgentSessionID.notNull() - && gMessageSystem->mOurCircuitCode - && gFirstSim.isOk()) - // OGPX : Inventory root might be null in OGP. -// && gAgent.mInventoryRootID.notNull()) + if(process_login_success_response(password)) { std::string name = firstname; std::string last_name = lastname; @@ -1894,6 +1586,8 @@ bool idle_startup() if(last_name != "resident") name += " " + lastname; gViewerWindow->getWindow()->setTitle(LLAppViewer::instance()->getWindowTitle() + "- " + name); + // Pass the user information to the voice chat server interface. + gVoiceClient->userAuthorized(firstname, lastname, gAgentID); LLStartUp::setStartupState( STATE_WORLD_INIT ); } else @@ -1912,11 +1606,8 @@ bool idle_startup() gSavedSettings.setBOOL("AutoLogin", FALSE); show_connect_box = true; } - - // Pass the user information to the voice chat server interface. - gVoiceClient->userAuthorized(firstname, lastname, gAgentID); } - else // if(successful_login) + else // if(!successful_login) { if (gNoRender) { @@ -2237,7 +1928,7 @@ bool idle_startup() // the coordinates handed to us to fit in the local region. gAgent.setPositionAgent(agent_start_position_region); - gAgent.resetAxes(agent_start_look_at); + gAgent.resetAxes(gAgentStartLookAt); gAgentCamera.stopCameraAnimation(); gAgentCamera.resetCamera(); display_startup(); @@ -2394,6 +2085,7 @@ bool idle_startup() msg->processAcks(); display_startup(); + if (gAgentMovementCompleted) { LLStartUp::setStartupState( STATE_INVENTORY_SEND ); @@ -2412,47 +2104,47 @@ bool idle_startup() LLAgentLanguage::update(); display_startup(); // unpack thin inventory - LLUserAuth::options_t options; - options.clear(); + LLSD response = LLUserAuth::getInstance()->getResponse(); //bool dump_buffer = false; - - if(LLUserAuth::getInstance()->getOptions("inventory-lib-root", options) - && !options.empty()) + + LLSD inv_lib_root = response["inventory-lib-root"]; + if(inv_lib_root.isDefined()) { // should only be one - LLUserAuth::response_t::iterator it; - it = options[0].find("folder_id"); - if(it != options[0].end()) + LLSD id = inv_lib_root[0]["folder_id"]; + if(id.isDefined()) { - gInventory.setLibraryRootFolderID(LLUUID((*it).second)); + gInventory.setLibraryRootFolderID(id.asUUID()); } } - options.clear(); - if(LLUserAuth::getInstance()->getOptions("inventory-lib-owner", options) - && !options.empty()) + display_startup(); + + LLSD inv_lib_owner = response["inventory-lib-owner"]; + if(inv_lib_owner.isDefined()) { // should only be one - LLUserAuth::response_t::iterator it; - it = options[0].find("agent_id"); - if(it != options[0].end()) + LLSD id = inv_lib_owner[0]["agent_id"]; + if(id.isDefined()) { - gInventory.setLibraryOwnerID(LLUUID((*it).second)); + gInventory.setLibraryOwnerID( LLUUID(id.asUUID())); } } - options.clear(); - if(LLUserAuth::getInstance()->getOptions("inventory-skel-lib", options) - && gInventory.getLibraryOwnerID().notNull()) + display_startup(); + + LLSD inv_skel_lib = response["inventory-skel-lib"]; + if(inv_skel_lib.isDefined() && gInventory.getLibraryOwnerID().notNull()) { - if(!gInventory.loadSkeleton(options, gInventory.getLibraryOwnerID())) + if(!gInventory.loadSkeleton(inv_skel_lib, gInventory.getLibraryOwnerID())) { LL_WARNS("AppInit") << "Problem loading inventory-skel-lib" << LL_ENDL; } } - options.clear(); display_startup(); - if(LLUserAuth::getInstance()->getOptions("inventory-skeleton", options)) + + LLSD inv_skeleton = response["inventory-skeleton"]; + if(inv_skeleton.isDefined()) { - if(!gInventory.loadSkeleton(options, gAgent.getID())) + if(!gInventory.loadSkeleton(inv_skeleton, gAgent.getID())) { LL_WARNS("AppInit") << "Problem loading inventory-skel-targets" << LL_ENDL; } @@ -2494,78 +2186,75 @@ bool idle_startup() display_startup(); // - options.clear(); - if(LLUserAuth::getInstance()->getOptions("buddy-list", options)) + LLSD buddy_list = response["buddy-list"]; + if(buddy_list.isDefined()) { - LLUserAuth::options_t::iterator it = options.begin(); - LLUserAuth::options_t::iterator end = options.end(); LLAvatarTracker::buddy_map_t list; LLUUID agent_id; S32 has_rights = 0, given_rights = 0; - for (; it != end; ++it) + for(LLSD::array_const_iterator it = buddy_list.beginArray(), + end = buddy_list.endArray(); it != end; ++it) { - LLUserAuth::response_t::const_iterator option_it; - option_it = (*it).find("buddy_id"); - if(option_it != (*it).end()) + LLSD buddy_id = (*it)["buddy_id"]; + if(buddy_id.isDefined()) { - agent_id.set((*option_it).second); + agent_id = buddy_id.asUUID(); } - option_it = (*it).find("buddy_rights_has"); - if(option_it != (*it).end()) + + LLSD buddy_rights_has = (*it)["buddy_rights_has"]; + if(buddy_rights_has.isDefined()) { - has_rights = atoi((*option_it).second.c_str()); + has_rights = buddy_rights_has.asInteger(); } - option_it = (*it).find("buddy_rights_given"); - if(option_it != (*it).end()) + + LLSD buddy_rights_given = (*it)["buddy_rights_given"]; + if(buddy_rights_given.isDefined()) { - given_rights = atoi((*option_it).second.c_str()); + given_rights = buddy_rights_given.asInteger(); } + list[agent_id] = new LLRelationship(given_rights, has_rights, false); } LLAvatarTracker::instance().addBuddyList(list); - } - display_startup(); - options.clear(); - if(LLUserAuth::getInstance()->getOptions("ui-config", options)) - { - LLUserAuth::options_t::iterator it = options.begin(); - LLUserAuth::options_t::iterator end = options.end(); - for (; it != end; ++it) + display_startup(); + } + + LLSD ui_config = response["ui-config"]; + if(ui_config.isDefined()) + { + for(LLSD::array_const_iterator it = ui_config.beginArray(), + end = ui_config.endArray(); it != end; ++it) { - LLUserAuth::response_t::const_iterator option_it; - option_it = (*it).find("allow_first_life"); - if(option_it != (*it).end()) + LLSD allow_first_life = (*it)["allow_first_life"]; + if(allow_first_life.isDefined()) { - if (option_it->second == "Y") + if (allow_first_life.asString() == "Y") { LLPanelAvatar::sAllowFirstLife = TRUE; } } } - } + } display_startup(); - options.clear(); + bool show_hud = false; - if(LLUserAuth::getInstance()->getOptions("tutorial_setting", options)) + LLSD tutorial_setting = response["tutorial_setting"]; + if(tutorial_setting.isDefined()) { - LLUserAuth::options_t::iterator it = options.begin(); - LLUserAuth::options_t::iterator end = options.end(); - for (; it != end; ++it) + for(LLSD::array_const_iterator it = tutorial_setting.beginArray(), + end = tutorial_setting.endArray(); it != end; ++it) { - LLUserAuth::response_t::const_iterator option_it; - option_it = (*it).find("tutorial_url"); - if(option_it != (*it).end()) + LLSD tutorial_url = (*it)["tutorial_url"]; + if(tutorial_url.isDefined()) { // Tutorial floater will append language code - gSavedSettings.setString("TutorialURL", option_it->second); + gSavedSettings.setString("TutorialURL", tutorial_url.asString()); } - option_it = (*it).find("use_tutorial"); - if(option_it != (*it).end()) + + LLSD use_tutorial = (*it)["use_tutorial"]; + if(use_tutorial.asString() == "true") { - if (option_it->second == "true") - { - show_hud = true; - } + show_hud = true; } } } @@ -2573,34 +2262,44 @@ bool idle_startup() // Either we want to show tutorial because this is the first login // to a Linden Help Island or the user quit with the tutorial // visible. JC - if (show_hud - || gSavedSettings.getBOOL("ShowTutorial")) + if (show_hud || gSavedSettings.getBOOL("ShowTutorial")) { LLFloaterHUD::showHUD(); } + display_startup(); + + LLSD event_categories = response["event_categories"]; + if(event_categories.isDefined()) + { + LLEventInfo::loadCategories(event_categories); + } + display_startup(); + + LLSD event_notifications = response["event_notifications"]; + if(event_notifications.isDefined()) + { + gEventNotifier.load(event_notifications); + } + display_startup(); - options.clear(); - if(LLUserAuth::getInstance()->getOptions("event_categories", options)) + LLSD classified_categories = response["classified_categories"]; + if(classified_categories.isDefined()) { - LLEventInfo::loadCategories(options); - } - if(LLUserAuth::getInstance()->getOptions("event_notifications", options)) - { - gEventNotifier.load(options); - } - display_startup(); - options.clear(); - if(LLUserAuth::getInstance()->getOptions("classified_categories", options)) - { - LLClassifiedInfo::loadCategories(options); + LLClassifiedInfo::loadCategories(classified_categories); } display_startup(); + + // This method MUST be called before gInventory.findCategoryUUIDForType because of + // gInventory.mIsAgentInvUsable is set to true in the gInventory.buildParentChildMap. gInventory.buildParentChildMap(); display_startup(); - llinfos << "Setting Inventory changed mask and notifying observers" << llendl; + /*llinfos << "Setting Inventory changed mask and notifying observers" << llendl; gInventory.addChangedMask(LLInventoryObserver::ALL, LLUUID::null); - gInventory.notifyObservers(); + gInventory.notifyObservers();*/ + + //all categories loaded. lets create "My Favorites" category + gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true); // set up callbacks llinfos << "Registering Callbacks" << llendl; @@ -2716,34 +2415,20 @@ bool idle_startup() // JC: Initialize "active" gestures. This may also trigger // many gesture downloads, if this is the user's first // time on this machine or -purge has been run. - LLUserAuth::options_t gesture_options; - if (LLUserAuth::getInstance()->getOptions("gestures", gesture_options)) + LLSD gesture_options + = LLUserAuth::getInstance()->getResponse("gestures"); + if (gesture_options.isDefined()) { LL_DEBUGS("AppInit") << "Gesture Manager loading " << gesture_options.size() << LL_ENDL; - std::vector item_ids; - LLUserAuth::options_t::iterator resp_it; - for (resp_it = gesture_options.begin(); - resp_it != gesture_options.end(); - ++resp_it) + uuid_vec_t item_ids; + for(LLSD::array_const_iterator resp_it = gesture_options.beginArray(), + end = gesture_options.endArray(); resp_it != end; ++resp_it) { - const LLUserAuth::response_t& response = *resp_it; - LLUUID item_id; - LLUUID asset_id; - LLUserAuth::response_t::const_iterator option_it; - - option_it = response.find("item_id"); - if (option_it != response.end()) - { - const std::string& uuid_string = (*option_it).second; - item_id.set(uuid_string); - } - option_it = response.find("asset_id"); - if (option_it != response.end()) - { - const std::string& uuid_string = (*option_it).second; - asset_id.set(uuid_string); - } + // If the id is not specifed in the LLSD, + // the LLSD operator[]() will return a null LLUUID. + LLUUID item_id = (*resp_it)["item_id"]; + LLUUID asset_id = (*resp_it)["asset_id"]; if (item_id.notNull() && asset_id.notNull()) { @@ -2796,19 +2481,12 @@ bool idle_startup() // JC - 7/20/2002 gViewerWindow->sendShapeToSim(); - - // Ignore stipend information for now. Money history is on the web site. - // if needed, show the L$ history window - //if (stipend_since_login && !gNoRender) - //{ - //} - if (!gAgent.isFirstLogin()) { bool url_ok = LLURLSimString::sInstance.parse(); - if (!((agent_start_location == "url" && url_ok) || - (!url_ok && ((agent_start_location == "last" && gSavedSettings.getBOOL("LoginLastLocation")) || - (agent_start_location == "home" && !gSavedSettings.getBOOL("LoginLastLocation")))))) + if (!((gAgentStartLocation == "url" && url_ok) || + (!url_ok && ((gAgentStartLocation == "last" && gSavedSettings.getBOOL("LoginLastLocation")) || + (gAgentStartLocation == "home" && !gSavedSettings.getBOOL("LoginLastLocation")))))) { // The reason we show the alert is because we want to // reduce confusion for when you log in and your provided @@ -3068,6 +2746,333 @@ bool idle_startup() return TRUE; } +bool process_login_success_response(std::string& password) +{ + LLSD response = LLUserAuth::getInstance()->getResponse(); + + std::string text(response["udp_blacklist"]); + if(!text.empty()) + { + apply_udp_blacklist(text); + } + + // unpack login data needed by the application + text = response["agent_id"].asString(); + if(!text.empty()) gAgentID.set(text); + gDebugInfo["AgentID"] = text; + + text = response["session_id"].asString(); + if(!text.empty()) gAgentSessionID.set(text); + gDebugInfo["SessionID"] = text; + + text = response["secure_session_id"].asString(); + if(!text.empty()) gAgent.mSecureSessionID.set(text); + + std::string firstname; + std::string lastname; + text = response["first_name"].asString(); + if(!text.empty()) + { + // Remove quotes from string. Login.cgi sends these to force + // names that look like numbers into strings. + firstname.assign(text); + LLStringUtil::replaceChar(firstname, '"', ' '); + LLStringUtil::trim(firstname); + } + text = response["last_name"].asString(); + if(!text.empty()) lastname.assign(text); + gSavedSettings.setString("FirstName", firstname); + gSavedSettings.setString("LastName", lastname); + // + gFullName = utf8str_tolower(firstname + " " + lastname); + // + + if (gSavedSettings.getBOOL("RememberPassword")) + { + // Successful login means the password is valid, so save it. + LLStartUp::savePasswordToDisk(password); + } + else + { + // Don't leave password from previous session sitting around + // during this login session. + LLStartUp::deletePasswordFromDisk(); + password.assign(""); // clear the password so it isn't saved to login history either + } + + { + // Save the login history data to disk + std::string history_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "saved_logins_sg2.xml"); + + LLSavedLogins history_data = LLSavedLogins::loadFile(history_file); + std::string grid_nick = gHippoGridManager->getConnectedGrid()->getGridName(); + history_data.deleteEntry(firstname, lastname, grid_nick); + if (gSavedSettings.getBOOL("RememberLogin")) + { + LLSavedLoginEntry login_entry(firstname, lastname, password, grid_nick); + history_data.addEntry(login_entry); + } + else + { + // Clear the old-style login data as well + gSavedSettings.setString("FirstName", std::string("")); + gSavedSettings.setString("LastName", std::string("")); + } + + LLSavedLogins::saveFile(history_data, history_file); + } + + // this is their actual ability to access content + text = response["agent_access_max"].asString(); + if (!text.empty()) + { + // agent_access can be 'A', 'M', and 'PG'. + gAgent.setMaturity(text[0]); + } + + // this is the value of their preference setting for that content + // which will always be <= agent_access_max + text = response["agent_region_access"].asString(); + if (!text.empty()) + { + U32 preferredMaturity = (U32)LLAgent::convertTextToMaturity(text[0]); + + gSavedSettings.setU32("PreferredMaturity", preferredMaturity); + } + // During the AO transition, this flag will be true. Then the flag will + // go away. After the AO transition, this code and all the code that + // uses it can be deleted. + text = response["ao_transition"].asString(); + if (!text.empty()) + { + if (text == "1") + { + gAgent.setAOTransition(); + } + } + + text = response["start_location"].asString(); + if(!text.empty()) + { + gAgentStartLocation.assign(text); + } + + text = response["circuit_code"].asString(); + if(!text.empty()) + { + gMessageSystem->mOurCircuitCode = strtoul(text.c_str(), NULL, 10); + } + std::string sim_ip_str = response["sim_ip"]; + std::string sim_port_str = response["sim_port"]; + if(!sim_ip_str.empty() && !sim_port_str.empty()) + { + U32 sim_port = strtoul(sim_port_str.c_str(), NULL, 10); + gFirstSim.set(sim_ip_str, sim_port); + if (gFirstSim.isOk()) + { + gMessageSystem->enableCircuit(gFirstSim, TRUE); + } + } + std::string region_x_str = response["region_x"]; + std::string region_y_str = response["region_y"]; + if(!region_x_str.empty() && !region_y_str.empty()) + { + U32 region_x = strtoul(region_x_str.c_str(), NULL, 10); + U32 region_y = strtoul(region_y_str.c_str(), NULL, 10); + gFirstSimHandle = to_region_handle(region_x, region_y); + } + + const std::string look_at_str = response["look_at"]; + if (!look_at_str.empty()) + { + size_t len = look_at_str.size(); + LLMemoryStream mstr((U8*)look_at_str.c_str(), len); + LLSD sd = LLSDSerialize::fromNotation(mstr, len); + gAgentStartLookAt = ll_vector3_from_sd(sd); + } + + text = response["seed_capability"].asString(); + if (!text.empty()) gFirstSimSeedCap = text; + + text = response["seconds_since_epoch"].asString(); + if(!text.empty()) + { + U32 server_utc_time = strtoul(text.c_str(), NULL, 10); + if(server_utc_time) + { + time_t now = time(NULL); + gUTCOffset = (server_utc_time - now); + } + } + + std::string home_location = response["home"]; + if(!home_location.empty()) + { + size_t len = home_location.size(); + LLMemoryStream mstr((U8*)home_location.c_str(), len); + LLSD sd = LLSDSerialize::fromNotation(mstr, len); + S32 region_x = sd["region_handle"][0].asInteger(); + S32 region_y = sd["region_handle"][1].asInteger(); + U64 region_handle = to_region_handle(region_x, region_y); + LLVector3 position = ll_vector3_from_sd(sd["position"]); + gAgent.setHomePosRegion(region_handle, position); + } + + gAgent.mMOTD.assign(response["message"]); + + // Options... + // Each 'option' is an array of submaps. + // It appears that we only ever use the first element of the array. + LLUUID inv_root_folder_id = response["inventory-root"][0]["folder_id"]; + if(inv_root_folder_id.notNull()) + { + gInventory.setRootFolderID(inv_root_folder_id); + //gInventory.mock(gAgent.getInventoryRootID()); + } + + LLSD login_flags = response["login-flags"][0]; + if(login_flags.size()) + { + std::string flag = login_flags["ever_logged_in"]; + if(!flag.empty()) + { + gAgent.setFirstLogin((flag == "N") ? TRUE : FALSE); + } + + /* Flag is currently ignored by the viewer. + flag = login_flags["stipend_since_login"]; + if(flag == "Y") + { + stipend_since_login = true; + } + */ + + flag = login_flags["gendered"].asString(); + if(flag == "Y") + { + gAgent.setGenderChosen(TRUE); + } + + flag = login_flags["daylight_savings"].asString(); + if(flag == "Y") + { + gPacificDaylightTime = (flag == "Y"); + } + } + std::string map_server_url = response["map-server-url"]; + if(!map_server_url.empty()) + { + gSavedSettings.setString("MapServerURL", map_server_url); + LLWorldMap::gotMapServerURL(true); + } + // Initial outfit for the user. + LLSD initial_outfit = response["initial-outfit"][0]; + if(initial_outfit.size()) + { + std::string flag = initial_outfit["folder_name"]; + if(!flag.empty()) + { + // Initial outfit is a folder in your inventory, + // must be an exact folder-name match. + sInitialOutfit = flag; + } + + flag = initial_outfit["gender"].asString(); + if(!flag.empty()) + { + sInitialOutfitGender = flag; + } + } + + LLSD global_textures = response["global-textures"][0]; + if(global_textures.size()) + { + // Extract sun and moon texture IDs. These are used + // in the LLVOSky constructor, but I can't figure out + // how to pass them in. JC + LLUUID id = global_textures["sun_texture_id"]; + if(id.notNull()) + { + gSunTextureID = id; + } + + id = global_textures["moon_texture_id"]; + if(id.notNull()) + { + gMoonTextureID = id; + } + + id = global_textures["cloud_texture_id"]; + if(id.notNull()) + { + gCloudTextureID = id; + } + } + + + // Override grid info with anything sent in the login response + std::string tmp = response["gridname"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setGridName(tmp); + tmp = response["loginuri"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginUri(tmp); + tmp = response["welcome"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginPage(tmp); + tmp = response["loginpage"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setLoginPage(tmp); + tmp = response["economy"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setHelperUri(tmp); + tmp = response["helperuri"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setHelperUri(tmp); + tmp = response["about"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setWebSite(tmp); + tmp = response["website"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setWebSite(tmp); + tmp = response["help"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSupportUrl(tmp); + tmp = response["support"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSupportUrl(tmp); + tmp = response["register"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRegisterUrl(tmp); + tmp = response["account"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRegisterUrl(tmp); + tmp = response["password"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setPasswordUrl(tmp); + tmp = response["search"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setSearchUrl(tmp); + tmp = response["currency"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setCurrencySymbol(tmp); + tmp = response["real_currency"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setRealCurrencySymbol(tmp); + tmp = response["directory_fee"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setDirectoryFee(atoi(tmp.c_str())); + tmp = response["max_groups"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setMaxAgentGroups(atoi(tmp.c_str())); + tmp = response["max-agent-groups"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setMaxAgentGroups(atoi(tmp.c_str())); + tmp = response["VoiceConnector"]; + if (!tmp.empty()) gHippoGridManager->getConnectedGrid()->setVoiceConnector(tmp); + gHippoGridManager->saveFile(); + gHippoLimits->setLimits(); + + gIMMgr->loadIgnoreGroup(); + + bool success = false; + // JC: gesture loading done below, when we have an asset system + // in place. Don't delete/clear user_credentials until then. + + if(gAgentID.notNull() + && gAgentSessionID.notNull() + && gMessageSystem->mOurCircuitCode + && gFirstSim.isOk() + && gInventory.getRootFolderID().notNull()) + { + success = true; + } + return success; +} + + + // // local function definition // diff --git a/indra/newview/lluserauth.cpp b/indra/newview/lluserauth.cpp index cd9716a7f..f558a3170 100644 --- a/indra/newview/lluserauth.cpp +++ b/indra/newview/lluserauth.cpp @@ -44,6 +44,7 @@ #include "llviewercontrol.h" #include "llxmlrpctransaction.h" #include "llsdutil.h" +#include "stringize.h" // NOTE: MUST include these after otherincludes since queue gets redefined!?!! #include @@ -86,7 +87,6 @@ void LLUserAuth::reset() delete mTransaction; mTransaction = NULL; mResponses.clear(); - mOptions.clear(); mResult.clear(); } @@ -319,51 +319,6 @@ LLUserAuth::UserAuthcode LLUserAuth::authResponse() return mAuthResponse; } -static void parseOptionInto( - const std::string& id, XMLRPC_VALUE option, LLUserAuth::options_t& options) -{ - std::string key; - std::string val; - XMLRPC_VALUE_TYPE_EASY type; - XMLRPC_VALUE row = XMLRPC_VectorRewind(option); - while(row) - { - XMLRPC_VALUE opt = XMLRPC_VectorRewind(row); - LLUserAuth::response_t responses; - while(opt) - { - key.assign(XMLRPC_GetValueID(opt)); - //llinfos << "option key: " << key << llendl; - type = XMLRPC_GetValueTypeEasy(opt); - if(xmlrpc_type_string == type) - { - val.assign(XMLRPC_GetValueString(opt)); - //llinfos << "string val: " << val << llendl; - } - else if(xmlrpc_type_int == type) - { - val = llformat("%d", XMLRPC_GetValueInt(opt)); - //llinfos << "int val: " << val << llendl; - } - else if(xmlrpc_type_double == type) - { - val = llformat("%g", XMLRPC_GetValueDouble(opt)); - //llinfos << "double val: " << val << llendl; - } - else - { // Can't understand the type - val = "???"; - //llinfos << "unknown value type: " << type << llendl; - } - - responses.insert(LLUserAuth::response_t::value_type(key, val)); - opt = XMLRPC_VectorNext(row); - } - options.push_back(responses); - row = XMLRPC_VectorNext(option); - } -} - LLUserAuth::UserAuthcode LLUserAuth::parseResponse() { // The job of this function is to parse sCurlDownloadArea and @@ -376,78 +331,90 @@ LLUserAuth::UserAuthcode LLUserAuth::parseResponse() // clear out any old parsing mResponses.clear(); - mOptions.clear(); // Now, parse everything - std::string key; - std::string val; - XMLRPC_VALUE param = NULL; - XMLRPC_VALUE current = NULL; - XMLRPC_VALUE_TYPE_EASY type; - param = XMLRPC_RequestGetData(response); - if(!param) goto exit; - current = XMLRPC_VectorRewind(param); - while(current) + XMLRPC_VALUE param = XMLRPC_RequestGetData(response); + if (! param) { - key.assign(XMLRPC_GetValueID(current)); - lldebugs << "key: " << key << llendl; - type = XMLRPC_GetValueTypeEasy(current); - if(xmlrpc_type_string == type) - { - val.assign(XMLRPC_GetValueString(current)); - lldebugs << "val: " << val << llendl; - mResponses.insert(response_t::value_type(key, val)); - } - else if(xmlrpc_type_int == type) - { - val = llformat( "%d", XMLRPC_GetValueInt(current)); - lldebugs << "val: " << val << llendl; - mResponses.insert(response_t::value_type(key, val)); - } - else if(xmlrpc_type_array == type) - { - options_t options; - parseOptionInto(key, current, options); - mOptions.insert(all_options_t::value_type(key, options)); - } - else - { - // whoops - bad response - llwarns << "Unhandled xmlrpc type, key, value: " << type << " " - << key << " " << val << "." << llendl; - rv = E_UNHANDLED_ERROR; - break; - } - current = XMLRPC_VectorNext(param); - rv = E_OK; + lldebugs << "Response contains no data" << LL_ENDL; + return rv; } - exit: + // Now, parse everything + mResponses = parseValues(rv, "", param); return rv; } -const std::string& LLUserAuth::getResponse(const std::string& key) const +LLSD LLUserAuth::parseValues(UserAuthcode &auth_code, const std::string& key_pfx, XMLRPC_VALUE param) { - response_t::const_iterator it = mResponses.find(key); - if(it != mResponses.end()) + auth_code = E_OK; + LLSD responses; + for(XMLRPC_VALUE current = XMLRPC_VectorRewind(param); current; + current = XMLRPC_VectorNext(param)) { - return((*it).second); - } - return LLStringUtil::null; -} - -BOOL LLUserAuth::getOptions(const std::string& key, options_t& options) const -{ - all_options_t::const_iterator it = mOptions.find(key); - if(it != mOptions.end()) - { - // found the option set, copy them onto the container. - std::back_insert_iterator ii(options); - std::copy((*it).second.begin(), (*it).second.end(), ii); - return TRUE; - } - return FALSE; + std::string key(XMLRPC_GetValueID(current)); + lldebugs << "key: " << key_pfx << key << llendl; + XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(current); + if(xmlrpc_type_string == type) + { + LLSD::String val(XMLRPC_GetValueString(current)); + lldebugs << "val: " << val << llendl; + responses.insert(key,val); + } + else if(xmlrpc_type_int == type) + { + LLSD::Integer val(XMLRPC_GetValueInt(current)); + lldebugs << "val: " << val << llendl; + responses.insert(key,val); + } + else if (xmlrpc_type_double == type) + { + LLSD::Real val(XMLRPC_GetValueDouble(current)); + lldebugs << "val: " << val << llendl; + responses.insert(key,val); + } + else if(xmlrpc_type_array == type) + { + // We expect this to be an array of submaps. Walk the array, + // recursively parsing each submap and collecting them. + LLSD array; + int i = 0; // for descriptive purposes + for (XMLRPC_VALUE row = XMLRPC_VectorRewind(current); row; + row = XMLRPC_VectorNext(current), ++i) + { + // Recursive call. For the lower-level key_pfx, if 'key' + // is "foo", pass "foo[0]:", then "foo[1]:", etc. In the + // nested call, a subkey "bar" will then be logged as + // "foo[0]:bar", and so forth. + // Parse the scalar subkey/value pairs from this array + // entry into a temp submap. Collect such submaps in 'array'. + std::string key_prefix = key_pfx; + array.append(parseValues(auth_code, + STRINGIZE(key_pfx << key << '[' << i << "]:"), + row)); + } + // Having collected an 'array' of 'submap's, insert that whole + // 'array' as the value of this 'key'. + responses.insert(key, array); + } + else if (xmlrpc_type_struct == type) + { + LLSD submap = parseValues(auth_code, + STRINGIZE(key_pfx << key << ':'), + current); + responses.insert(key, submap); + } + else + { + // whoops - unrecognized type + llwarns << "Unhandled xmlrpc type " << type << " for key " + << key_pfx << key << LL_ENDL; + responses.insert(key, STRINGIZE("')); + auth_code = E_UNHANDLED_ERROR; + } + } + return responses; } - + diff --git a/indra/newview/lluserauth.h b/indra/newview/lluserauth.h index 85cc18016..e0160d874 100644 --- a/indra/newview/lluserauth.h +++ b/indra/newview/lluserauth.h @@ -90,10 +90,6 @@ public: E_LAST // never use! } UserAuthcode; - // used for holding options - typedef std::map response_t; - typedef std::vector options_t; - // viewer auth version void authenticate( const std::string& auth_uri, @@ -140,8 +136,8 @@ public: // function to get a direct reponse from the login api by // name. returns NULL if the named response was not found. - const std::string& getResponse(const std::string& name) const; - BOOL getOptions(const std::string& name, options_t& options) const; + LLSD getResponse() const { return mResponses; } + LLSD getResponse(const std::string& entry) const { return mResponses[entry]; } F64 getLastTransferRateBPS() const { return mLastTransferRateBPS; } @@ -152,12 +148,12 @@ private: std::string mErrorMessage; // dealing with the XML - typedef std::map all_options_t; - response_t mResponses; - all_options_t mOptions; + LLSD mResponses; UserAuthcode parseResponse(); + LLSD parseValues(UserAuthcode &auth_code, const std::string& key_pfx, XMLRPC_VALUE param); + F64 mLastTransferRateBPS; // bits per second, only valid after a big transfer like inventory }; diff --git a/indra/newview/llviewertextureanim.cpp b/indra/newview/llviewertextureanim.cpp index 73b166093..9f1ac7c49 100644 --- a/indra/newview/llviewertextureanim.cpp +++ b/indra/newview/llviewertextureanim.cpp @@ -2,31 +2,25 @@ * @file llviewertextureanim.cpp * @brief LLViewerTextureAnim class implementation * - * $LicenseInfo:firstyear=2003&license=viewergpl$ - * - * Copyright (c) 2003-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ diff --git a/indra/newview/llviewertextureanim.h b/indra/newview/llviewertextureanim.h index d653e6bd3..dd7bd0cb9 100644 --- a/indra/newview/llviewertextureanim.h +++ b/indra/newview/llviewertextureanim.h @@ -2,31 +2,25 @@ * @file llviewertextureanim.h * @brief LLViewerTextureAnim class header file * - * $LicenseInfo:firstyear=2003&license=viewergpl$ - * - * Copyright (c) 2003-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */