summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rwxr-xr-xindra/newview/llviewermessage.cpp219
1 files changed, 160 insertions, 59 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 3574d37adf..d7ec4e0ead 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -116,6 +116,7 @@
#include <boost/regex.hpp>
#include "llnotificationmanager.h" //
+#include "llexperiencecache.h"
#if LL_MSVC
// disable boost::lexical_cast warning
@@ -5881,39 +5882,38 @@ bool handle_teleport_access_blocked(LLSD& llsdBlock)
return returnValue;
}
-bool attempt_standard_notification(LLMessageSystem* msgsystem)
+bool handle_home_position_set(std::string notificationID, LLSD& llsdBlock)
{
- // if we have additional alert data
- if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0)
- {
- // notification was specified using the new mechanism, so we can just handle it here
- std::string notificationID;
- msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
- if (!LLNotifications::getInstance()->templateExists(notificationID))
- {
- return false;
- }
+ std::string snap_filename = gDirUtilp->getLindenUserDir();
+ snap_filename += gDirUtilp->getDirDelimiter();
+ snap_filename += SCREEN_HOME_FILENAME;
+ gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
- std::string llsdRaw;
- LLSD llsdBlock;
- msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
- msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsdRaw);
- if (llsdRaw.length())
- {
- std::istringstream llsdData(llsdRaw);
- if (!LLSDSerialize::deserialize(llsdBlock, llsdData, llsdRaw.length()))
- {
- llwarns << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << llendl;
- }
- }
-
- if (
- (notificationID == "RegionEntryAccessBlocked") ||
- (notificationID == "LandClaimAccessBlocked") ||
- (notificationID == "LandBuyAccessBlocked")
- )
- {
- /*---------------------------------------------------------------------
+ return false;
+}
+
+bool handle_experience_maturity_exceeded(std::string notificationID, LLSD& llsdBlock)
+{
+ if(llsdBlock.has("experience_id"))
+ {
+ llsdBlock["EXPERIENCE_SLURL"]=LLSLURL("experience", llsdBlock["experience_id"].asUUID(), "profile").getSLURLString();
+ }
+ return false;
+}
+
+typedef boost::function<bool (std::string&, LLSD&)> standard_exception_function_t;
+typedef std::map<std::string, standard_exception_function_t> standard_exception_map_t;
+
+standard_exception_map_t sStandardExceptions;
+
+bool process_exceptions(std::string notificationID, LLSD& llsdBlock)
+{
+ if(sStandardExceptions.empty())
+ {
+ sStandardExceptions["RegionEntryAccessBlocked"] = handle_special_notification;
+ sStandardExceptions["LandClaimAccessBlocked"] = handle_special_notification;
+ sStandardExceptions["LandBuyAccessBlocked"] = handle_special_notification;
+ /*---------------------------------------------------------------------
(Commented so a grep will find the notification strings, since
we construct them on the fly; if you add additional notifications,
please update the comment.)
@@ -5938,21 +5938,55 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem)
LandBuyAccessBlocked_AdultsOnlyContent
-----------------------------------------------------------------------*/
- if (handle_special_notification(notificationID, llsdBlock))
- {
- return true;
- }
+
+
+ sStandardExceptions["HomePositionSet"] = handle_home_position_set;
+ sStandardExceptions["ExperienceMaturityExceeded"] = handle_experience_maturity_exceeded;
+ }
+
+ standard_exception_map_t::iterator it = sStandardExceptions.find(notificationID);
+
+ if(it == sStandardExceptions.end())
+ {
+ return false;
+ }
+
+ return it->second(notificationID, llsdBlock);
+}
+
+
+
+bool attempt_standard_notification(LLMessageSystem* msgsystem)
+{
+ // if we have additional alert data
+ if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0)
+ {
+ // notification was specified using the new mechanism, so we can just handle it here
+ std::string notificationID;
+ msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
+ if (!LLNotifications::getInstance()->templateExists(notificationID))
+ {
+ return false;
}
- // HACK -- handle callbacks for specific alerts.
- if( notificationID == "HomePositionSet" )
+
+ std::string llsdRaw;
+ LLSD llsdBlock;
+ msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
+ msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsdRaw);
+ if (llsdRaw.length())
{
- // save the home location image to disk
- std::string snap_filename = gDirUtilp->getLindenUserDir();
- snap_filename += gDirUtilp->getDirDelimiter();
- snap_filename += SCREEN_HOME_FILENAME;
- gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
+ std::istringstream llsdData(llsdRaw);
+ if (!LLSDSerialize::deserialize(llsdBlock, llsdData, llsdRaw.length()))
+ {
+ llwarns << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << llendl;
+ }
}
-
+
+ if(process_exceptions(notificationID, llsdBlock))
+ {
+ return true;
+ }
+
LLNotificationsUtil::add(notificationID, llsdBlock);
return true;
}
@@ -6347,6 +6381,12 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
return false;
}
+ LLUUID experience;
+ if(notification["payload"].has("experience"))
+ {
+ experience = notification["payload"]["experience"].asUUID();
+ }
+
// check whether permissions were granted or denied
BOOL allowed = TRUE;
// the "yes/accept" button is the first button in the template, making it button 0
@@ -6355,7 +6395,17 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
{
new_questions = 0;
allowed = FALSE;
- }
+ }
+ else if(experience.notNull())
+ {
+ LLSD permission;
+ LLSD data;
+ permission["permission"]="Allow";
+
+ data[experience.asString()]=permission;
+ data["experience"]=experience;
+ LLEventPumps::instance().obtain("experience_permission").post(data);
+ }
LLUUID task_id = notification["payload"]["task_id"].asUUID();
LLUUID item_id = notification["payload"]["item_id"].asUUID();
@@ -6381,6 +6431,29 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
if ( response["Mute"] ) // mute
{
script_question_mute(task_id,notification["payload"]["object_name"].asString());
+ }
+
+ if ( response["BlockExperience"] )
+ {
+ if(experience.notNull())
+ {
+ LLViewerRegion* region = gAgent.getRegion();
+ if (!region)
+ return false;
+
+ std::string lookup_url=region->getCapability("ExperiencePreferences");
+ if(lookup_url.empty())
+ return false;
+ LLSD permission;
+ LLSD data;
+ permission["permission"]="Block";
+
+ data[experience.asString()]=permission;
+ LLHTTPClient::put(lookup_url, data, NULL);
+
+ data["experience"]=experience;
+ LLEventPumps::instance().obtain("experience_permission").post(data);
+ }
}
return false;
@@ -6415,8 +6488,26 @@ void script_question_mute(const LLUUID& task_id, const std::string& object_name)
static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb);
static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb);
+static LLNotificationFunctorRegistration script_question_cb_reg_3("ScriptQuestionExperience", script_question_cb);
static LLNotificationFunctorRegistration unknown_script_question_cb_reg("UnknownScriptQuestion", unknown_script_question_cb);
+
+void process_script_experience_details(const LLSD& experience_details, LLSD args, LLSD payload)
+{
+ if(experience_details[LLExperienceCache::PROPERTIES].asInteger() & LLExperienceCache::PROPERTY_GRID)
+ {
+ args["GRID_WIDE"] = LLTrans::getString("GRID_WIDE")+ " ";
+ }
+ else
+ {
+ args["GRID_WIDE"] = "";
+ }
+ args["EXPERIENCE"] = LLSLURL("experience", experience_details[LLExperienceCache::EXPERIENCE_ID].asUUID(), "profile").getSLURLString();
+
+ LLNotificationsUtil::add("ScriptQuestionExperience", args, payload);
+}
+
+
void process_script_question(LLMessageSystem *msg, void **user_data)
{
// *TODO: Translate owner name -> [FIRST] [LAST]
@@ -6428,6 +6519,9 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
S32 questions;
std::string object_name;
std::string owner_name;
+ LLUUID experienceid;
+
+
// taskid -> object key of object requesting permissions
msg->getUUIDFast(_PREHASH_Data, _PREHASH_TaskID, taskid );
@@ -6437,6 +6531,11 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, owner_name);
msg->getS32Fast(_PREHASH_Data, _PREHASH_Questions, questions );
+ if(msg->has(_PREHASH_Experience))
+ {
+ msg->getUUIDFast(_PREHASH_Experience, _PREHASH_ExperienceID, experienceid);
+ }
+
// Special case. If the objects are owned by this agent, throttle per-object instead
// of per-owner. It's common for residents to reset a ton of scripts that re-request
// permissions, as with tier boxes. UUIDs can't be valid agent names and vice-versa,
@@ -6522,26 +6621,28 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
payload["object_name"] = object_name;
payload["owner_name"] = owner_name;
- // check whether cautions are even enabled or not
- if (gSavedSettings.getBOOL("PermissionsCautionEnabled"))
- {
- if (caution)
- {
- args["FOOTERTEXT"] = (count > 1) ? LLTrans::getString("AdditionalPermissionsRequestHeader") + "\n\n" + script_question : "";
- }
- // display the caution permissions prompt
- LLNotificationsUtil::add(caution ? "ScriptQuestionCaution" : "ScriptQuestion", args, payload);
- }
- else
- {
- // fall back to default behavior if cautions are entirely disabled
- LLNotificationsUtil::add("ScriptQuestion", args, payload);
- }
+
+ const char* notification = "ScriptQuestion";
+
+ if(caution && gSavedSettings.getBOOL("PermissionsCautionEnabled"))
+ {
+ args["FOOTERTEXT"] = (count > 1) ? LLTrans::getString("AdditionalPermissionsRequestHeader") + "\n\n" + script_question : "";
+ notification = "ScriptQuestionCaution";
+ }
+ else if(experienceid.notNull())
+ {
+ payload["experience"]=experienceid;
+ LLExperienceCache::get(experienceid, boost::bind(process_script_experience_details, _1, args, payload));
+ return;
+ }
+
+ LLNotificationsUtil::add(notification, args, payload);
}
}
}
+
void process_derez_container(LLMessageSystem *msg, void**)
{
LL_WARNS("Messaging") << "call to deprecated process_derez_container" << LL_ENDL;