From ecdc5cf7647c0cbbb057dba2f4bdeaafc3f5a93f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 17 May 2012 14:50:33 -0700 Subject: EXP-1928: Handling the rare case that the user preferences cannot be successfully changed, and reporting that to the user. --- indra/newview/llviewermessage.cpp | 102 +++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 8 deletions(-) (limited to 'indra/newview/llviewermessage.cpp') diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d88a6f1a9b..84de54986f 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -42,6 +42,7 @@ #include "llinventorydefines.h" #include "lllslconstants.h" #include "llregionhandle.h" +#include "llsd.h" #include "llsdserialize.h" #include "llteleportflags.h" #include "lltransactionflags.h" @@ -107,6 +108,7 @@ #include "llagentui.h" #include "llpanelblockedlist.h" #include "llpanelplaceprofile.h" +#include "llviewerregion.h" #include // #include @@ -5385,18 +5387,102 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) } } -void handle_maturity_preference_change(const LLSD &pResponse, int pMaturityRatingChange) +void handle_maturity_preference_change(const LLSD &pResponse, U8 pMaturityRatingChange) { - if (pResponse.isUndefined()) + bool isMaturityPreferenceElevated = false; + U8 actualPrefValue = SIM_ACCESS_MIN; + + llassert(!pResponse.isUndefined()); + llassert(pResponse.isMap()); + llassert(pResponse.has("access_prefs")); + llassert(pResponse.get("access_prefs").isMap()); + llassert(pResponse.get("access_prefs").has("max")); + llassert(pResponse.get("access_prefs").get("max").isString()); + + if (!pResponse.isUndefined() && pResponse.isMap() && pResponse.has("access_prefs") && + pResponse.get("access_prefs").isMap() && pResponse.get("access_prefs").has("max") && + pResponse.get("access_prefs").get("max").isString()) { - // XXX stinson 05/15/2012 : should report some notification that the preference has not changed - gAgent.clearFailedTeleportRequest(); + LLSD::String actualPreference = pResponse.get("access_prefs").get("max").asString(); + LLStringUtil::trim(actualPreference); + actualPrefValue = LLViewerRegion::shortStringToAccess(actualPreference); } - else + + switch (actualPrefValue) + { + case SIM_ACCESS_MIN : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_PG : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_MATURE : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + isMaturityPreferenceElevated = true; + break; + case SIM_ACCESS_ADULT : + default : + isMaturityPreferenceElevated = false; + break; + } + break; + case SIM_ACCESS_ADULT : + switch (pMaturityRatingChange) + { + case SIM_ACCESS_MIN : + case SIM_ACCESS_PG : + case SIM_ACCESS_MATURE : + case SIM_ACCESS_ADULT : + isMaturityPreferenceElevated = true; + break; + default : + isMaturityPreferenceElevated = false; + break; + } + break; + default : + isMaturityPreferenceElevated = false; + break; + } + + if (isMaturityPreferenceElevated) { gAgent.setMaturityRatingChangeDuringTeleport(pMaturityRatingChange); gAgent.restartFailedTeleportRequest(); } + else + { + LLSD args; + args["RATING"] = LLViewerRegion::accessToString(pMaturityRatingChange); + LLNotificationsUtil::add("MaturityCouldNotBeChanged", args); + gAgent.clearFailedTeleportRequest(); + } } bool handle_special_notification_callback(const LLSD& notification, const LLSD& response) @@ -5406,8 +5492,8 @@ bool handle_special_notification_callback(const LLSD& notification, const LLSD& if (0 == option) { // set the preference to the maturity of the region we're calling - int preferredMaturity = notification["payload"]["_region_access"].asInteger(); - gSavedSettings.setU32("PreferredMaturity", preferredMaturity); + U8 preferredMaturity = static_cast(notification["payload"]["_region_access"].asInteger()); + gSavedSettings.setU32("PreferredMaturity", static_cast(preferredMaturity)); gAgent.sendMaturityPreferenceToServer(preferredMaturity, boost::bind(&handle_maturity_preference_change, _1, preferredMaturity)); } else @@ -5421,7 +5507,7 @@ bool handle_special_notification_callback(const LLSD& notification, const LLSD& // some of the server notifications need special handling. This is where we do that. bool handle_special_notification(std::string notificationID, LLSD& llsdBlock) { - int regionAccess = llsdBlock["_region_access"].asInteger(); + U8 regionAccess = static_cast(llsdBlock["_region_access"].asInteger()); llsdBlock["REGIONMATURITY"] = LLViewerRegion::accessToString(regionAccess); bool returnValue = false; -- cgit v1.2.3