summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
authorTodd Stinson <stinson@lindenlab.com>2012-05-25 18:45:27 -0700
committerTodd Stinson <stinson@lindenlab.com>2012-05-25 18:45:27 -0700
commitb8bc62a514786121ac34857c0e052040e603d4e4 (patch)
treebfcfda56d2331d92efe98294f68b04146b15770d /indra/newview/llviewermessage.cpp
parentb2b446aed7f7f32151bc152ba25d44253ebf864f (diff)
parent403ed9656bf4c0c92004cce44d08972b9bd6ee43 (diff)
Pull and merge from ssh://hg@bitbucket.org/lindenlab/viewer-release.
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rwxr-xr-xindra/newview/llviewermessage.cpp229
1 files changed, 200 insertions, 29 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 854e2bea52..932735971e 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 <boost/algorithm/string/split.hpp> //
#include <boost/regex.hpp>
@@ -5389,23 +5391,114 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
}
}
+void handle_maturity_preference_change_and_reteleport(U8 pActualMaturityRating, U8 pRequestedMaturityRating)
+{
+ bool isMaturityPreferenceElevated = false;
+ switch (pActualMaturityRating)
+ {
+ case SIM_ACCESS_MIN :
+ switch (pRequestedMaturityRating)
+ {
+ 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 (pRequestedMaturityRating)
+ {
+ 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 (pRequestedMaturityRating)
+ {
+ 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 (pRequestedMaturityRating)
+ {
+ 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;
+ }
-bool handle_special_notification_callback(const LLSD& notification, const LLSD& response)
+ if (isMaturityPreferenceElevated)
+ {
+ gAgent.setMaturityRatingChangeDuringTeleport(pActualMaturityRating);
+ gAgent.restartFailedTeleportRequest();
+ }
+ else
+ {
+ LLSD args;
+ args["RATING"] = LLViewerRegion::accessToString(pRequestedMaturityRating);
+ LLNotificationsUtil::add("MaturityCouldNotBeChanged", args);
+ gAgent.clearFailedTeleportRequest();
+ }
+}
+
+bool handle_prompt_for_maturity_level_change_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
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);
- gAgent.sendMaturityPreferenceToServer(preferredMaturity);
+ U8 preferredMaturity = static_cast<U8>(notification["payload"]["_region_access"].asInteger());
+ gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(preferredMaturity));
+ }
+
+ return false;
+}
- // notify user that the maturity preference has been changed
- LLSD args;
- args["RATING"] = LLViewerRegion::accessToString(preferredMaturity);
- LLNotificationsUtil::add("PreferredMaturityChanged", args);
+bool handle_prompt_for_maturity_level_change_and_reteleport_callback(const LLSD& notification, const LLSD& response)
+{
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+
+ if (0 == option)
+ {
+ // set the preference to the maturity of the region we're calling
+ U8 preferredMaturity = static_cast<U8>(notification["payload"]["_region_access"].asInteger());
+ gAgent.setMaturityPreferenceAndConfirm(static_cast<U32>(preferredMaturity), boost::bind(&handle_maturity_preference_change_and_reteleport, _1, preferredMaturity));
+ }
+ else
+ {
+ gAgent.clearFailedTeleportRequest();
}
return false;
@@ -5414,39 +5507,86 @@ 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();
- llsdBlock["REGIONMATURITY"] = LLViewerRegion::accessToString(regionAccess);
-
- // we're going to throw the LLSD in there in case anyone ever wants to use it
- LLNotificationsUtil::add(notificationID+"_Notify", llsdBlock);
+ U8 regionAccess = static_cast<U8>(llsdBlock["_region_access"].asInteger());
+ std::string regionMaturity = LLViewerRegion::accessToString(regionAccess);
+ LLStringUtil::toLower(regionMaturity);
+ llsdBlock["REGIONMATURITY"] = regionMaturity;
+ bool returnValue = false;
+ LLNotificationPtr maturityLevelNotification;
+ std::string notifySuffix = "_Notify";
if (regionAccess == SIM_ACCESS_MATURE)
{
if (gAgent.isTeen())
{
- LLNotificationsUtil::add(notificationID+"_KB", llsdBlock);
- return true;
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
+ returnValue = true;
+
+ notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG())
{
- LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_special_notification_callback);
- return true;
+ if ((LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0) &&
+ gAgent.hasRestartableFailedTeleportRequest())
+ {
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback);
+ returnValue = true;
+ }
+ else
+ {
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
+ returnValue = true;
+ }
+ }
+ else if (LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0)
+ {
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
+ returnValue = true;
}
}
else if (regionAccess == SIM_ACCESS_ADULT)
{
if (!gAgent.isAdult())
{
- LLNotificationsUtil::add(notificationID+"_KB", llsdBlock);
- return true;
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
+ returnValue = true;
+
+ notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG() || gAgent.prefersMature())
{
- LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_special_notification_callback);
- return true;
+ if ((LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0) &&
+ gAgent.hasRestartableFailedTeleportRequest())
+ {
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback);
+ returnValue = true;
+ }
+ else
+ {
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
+ returnValue = true;
+ }
+ }
+ else if (LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0)
+ {
+ gAgent.clearFailedTeleportRequest();
+ maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
+ returnValue = true;
}
}
- return false;
+
+ if ((maturityLevelNotification == NULL) || maturityLevelNotification->isIgnored())
+ {
+ // Given a simple notification if no maturityLevelNotification is set or it is ignore
+ LLNotificationsUtil::add(notificationID + notifySuffix, llsdBlock);
+ }
+
+ return returnValue;
}
bool attempt_standard_notification(LLMessageSystem* msgsystem)
@@ -5490,16 +5630,20 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem)
RegionEntryAccessBlocked
RegionEntryAccessBlocked_Notify
+ RegionEntryAccessBlocked_NotifyAdultsOnly
RegionEntryAccessBlocked_Change
- RegionEntryAccessBlocked_KB
+ RegionEntryAccessBlocked_AdultsOnlyContent
+ RegionEntryAccessBlocked_ChangeAndReTeleport
LandClaimAccessBlocked
LandClaimAccessBlocked_Notify
+ LandClaimAccessBlocked_NotifyAdultsOnly
LandClaimAccessBlocked_Change
- LandClaimAccessBlocked_KB
+ LandClaimAccessBlocked_AdultsOnlyContent
LandBuyAccessBlocked
LandBuyAccessBlocked_Notify
+ LandBuyAccessBlocked_NotifyAdultsOnly
LandBuyAccessBlocked_Change
- LandBuyAccessBlocked_KB
+ LandBuyAccessBlocked_AdultsOnlyContent
-----------------------------------------------------------------------*/
if (handle_special_notification(notificationID, llsdBlock))
@@ -5551,6 +5695,30 @@ void process_alert_message(LLMessageSystem *msgsystem, void **user_data)
}
}
+bool handle_not_age_verified_alert(const std::string &pAlertName)
+{
+ LLNotificationPtr notification = LLNotificationsUtil::add(pAlertName);
+ if ((notification == NULL) || notification->isIgnored())
+ {
+ LLNotificationsUtil::add(pAlertName + "_Notify");
+ }
+
+ return true;
+}
+
+bool handle_special_alerts(const std::string &pAlertName)
+{
+ bool isHandled = false;
+
+ if (LLStringUtil::compareStrings(pAlertName, "NotAgeVerified") == 0)
+ {
+
+ isHandled = handle_not_age_verified_alert(pAlertName);
+ }
+
+ return isHandled;
+}
+
void process_alert_core(const std::string& message, BOOL modal)
{
// HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml
@@ -5574,7 +5742,10 @@ void process_alert_core(const std::string& message, BOOL modal)
// Allow the server to spawn a named alert so that server alerts can be
// translated out of English.
std::string alert_name(message.substr(ALERT_PREFIX.length()));
- LLNotificationsUtil::add(alert_name);
+ if (!handle_special_alerts(alert_name))
+ {
+ LLNotificationsUtil::add(alert_name);
+ }
}
else if (message.find(NOTIFY_PREFIX) == 0)
{
@@ -6151,6 +6322,9 @@ void process_teleport_failed(LLMessageSystem *msg, void**)
std::string big_reason;
LLSD args;
+ // Let the interested parties know that teleport failed.
+ LLViewerParcelMgr::getInstance()->onTeleportFailed();
+
// if we have additional alert data
if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0)
{
@@ -6209,9 +6383,6 @@ void process_teleport_failed(LLMessageSystem *msg, void**)
LLNotificationsUtil::add("CouldNotTeleportReason", args);
- // Let the interested parties know that teleport failed.
- LLViewerParcelMgr::getInstance()->onTeleportFailed();
-
if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
{
gAgent.setTeleportState( LLAgent::TELEPORT_NONE );