summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r--[-rwxr-xr-x]indra/newview/llviewermessage.cpp204
1 files changed, 91 insertions, 113 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index e570657cf9..92df3866f7 100755..100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -33,7 +33,6 @@
#include "llaudioengine.h"
#include "llavataractions.h"
#include "llavatarnamecache.h" // IDEVO HACK
-#include "lscript_byteformat.h"
#include "lleconomy.h"
#include "lleventtimer.h"
#include "llfloaterreg.h"
@@ -78,6 +77,7 @@
#include "llpanelgrouplandmoney.h"
#include "llrecentpeople.h"
#include "llscriptfloater.h"
+#include "llscriptruntimeperms.h"
#include "llselectmgr.h"
#include "llstartup.h"
#include "llsky.h"
@@ -117,10 +117,13 @@
#include <boost/algorithm/string/split.hpp> //
#include <boost/regex.hpp>
+#include <boost/foreach.hpp>
#include "llnotificationmanager.h" //
#include "llexperiencecache.h"
+#include "llexperiencecache.h"
+
#if LL_MSVC
// disable boost::lexical_cast warning
#pragma warning (disable:4702)
@@ -157,47 +160,6 @@ const U8 AU_FLAGS_NONE = 0x00;
const U8 AU_FLAGS_HIDETITLE = 0x01;
const U8 AU_FLAGS_CLIENT_AUTOPILOT = 0x02;
-//script permissions
-const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] =
- {
- "ScriptTakeMoney",
- "ActOnControlInputs",
- "RemapControlInputs",
- "AnimateYourAvatar",
- "AttachToYourAvatar",
- "ReleaseOwnership",
- "LinkAndDelink",
- "AddAndRemoveJoints",
- "ChangePermissions",
- "TrackYourCamera",
- "ControlYourCamera",
- "TeleportYourAgent",
- "JoinAnExperience",
- "SilentlyManageEstateAccess",
- "OverrideYourAnimations",
- "ScriptReturnObjects"
- };
-
-const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] =
-{
- TRUE, // ScriptTakeMoney,
- FALSE, // ActOnControlInputs
- FALSE, // RemapControlInputs
- FALSE, // AnimateYourAvatar
- FALSE, // AttachToYourAvatar
- FALSE, // ReleaseOwnership,
- FALSE, // LinkAndDelink,
- FALSE, // AddAndRemoveJoints
- FALSE, // ChangePermissions
- FALSE, // TrackYourCamera,
- FALSE, // ControlYourCamera
- FALSE, // TeleportYourAgent
- FALSE, // JoinAnExperience
- FALSE, // SilentlyManageEstateAccess
- FALSE, // OverrideYourAnimations
- FALSE, // ScriptReturnObjects
-};
-
bool friendship_offer_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
@@ -2360,6 +2322,20 @@ static void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::s
}
}
+const std::string NOT_ONLINE_MSG("User not online - message will be stored and delivered later.");
+const std::string NOT_ONLINE_INVENTORY("User not online - inventory has been saved.");
+void translate_if_needed(std::string& message)
+{
+ if (message == NOT_ONLINE_MSG)
+ {
+ message = LLTrans::getString("not_online_msg");
+ }
+ else if (message == NOT_ONLINE_INVENTORY)
+ {
+ message = LLTrans::getString("not_online_inventory");
+ }
+}
+
void process_improved_im(LLMessageSystem *msg, void **user_data)
{
LLUUID from_id;
@@ -2424,6 +2400,11 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
chat.mFromID = from_id;
chat.mFromName = name;
chat.mSourceType = (from_id.isNull() || (name == std::string(SYSTEM_FROM))) ? CHAT_SOURCE_SYSTEM : CHAT_SOURCE_AGENT;
+
+ if (chat.mSourceType == CHAT_SOURCE_SYSTEM)
+ { // Translate server message if required (MAINT-6109)
+ translate_if_needed(message);
+ }
LLViewerObject *source = gObjectList.findObject(session_id); //Session ID is probably the wrong thing.
if (source)
@@ -2468,7 +2449,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
buffer = message;
- LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
+ LL_DEBUGS("Messaging") << "session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
// add to IM panel, but do not bother the user
gIMMgr->addMessage(
@@ -2517,7 +2498,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
}
buffer = saved + message;
- LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
+ LL_DEBUGS("Messaging") << "session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
bool mute_im = is_muted;
if(accept_im_from_only_friend && !is_friend && !is_linden)
@@ -2683,6 +2664,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
payload["sender_name"] = name;
payload["group_id"] = group_id;
payload["inventory_name"] = item_name;
+ payload["received_time"] = LLDate::now();
if(info && info->asLLSD())
{
payload["inventory_offer"] = info->asLLSD();
@@ -2981,7 +2963,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
buffer = message;
- LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
+ LL_DEBUGS("Messaging") << "message in dnd; session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
// add to IM panel, but do not bother the user
gIMMgr->addMessage(
@@ -3008,7 +2990,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
buffer = saved + message;
- LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
+ LL_DEBUGS("Messaging") << "standard message session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
gIMMgr->addMessage(
session_id,
@@ -3060,6 +3042,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
{
send_do_not_disturb_message(msg, from_id);
}
+ else if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL))
+ {
+ return;
+ }
else
{
LLVector3 pos, look_at;
@@ -3489,53 +3475,29 @@ void process_decline_callingcard(LLMessageSystem* msg, void**)
LLNotificationsUtil::add("CallingCardDeclined");
}
-class ChatTranslationReceiver : public LLTranslate::TranslationReceiver
+void translateSuccess(LLChat chat, LLSD toastArgs, std::string originalMsg, std::string expectLang, std::string translation, const std::string detected_language)
{
-public :
- ChatTranslationReceiver(const std::string &from_lang, const std::string &to_lang, const std::string &mesg,
- const LLChat &chat, const LLSD &toast_args)
- : LLTranslate::TranslationReceiver(from_lang, to_lang),
- m_chat(chat),
- m_toastArgs(toast_args),
- m_origMesg(mesg)
- {
- }
-
- static ChatTranslationReceiver* build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
- {
- return new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args);
- }
-
-protected:
- void handleResponse(const std::string &translation, const std::string &detected_language)
- {
- // filter out non-interesting responeses
- if ( !translation.empty()
- && (mToLang != detected_language)
- && (LLStringUtil::compareInsensitive(translation, m_origMesg) != 0) )
- {
- m_chat.mText += " (" + translation + ")";
- }
+ // filter out non-interesting responses
+ if (!translation.empty()
+ && ((detected_language.empty()) || (expectLang != detected_language))
+ && (LLStringUtil::compareInsensitive(translation, originalMsg) != 0))
+ {
+ chat.mText += " (" + translation + ")";
+ }
- LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs);
- }
+ LLNotificationsUI::LLNotificationManager::instance().onChat(chat, toastArgs);
+}
- void handleFailure(int status, const std::string& err_msg)
- {
- LL_WARNS() << "Translation failed for mesg " << m_origMesg << " toLang " << mToLang << " fromLang " << mFromLang << LL_ENDL;
+void translateFailure(LLChat chat, LLSD toastArgs, int status, const std::string err_msg)
+{
+ std::string msg = LLTrans::getString("TranslationFailed", LLSD().with("[REASON]", err_msg));
+ LLStringUtil::replaceString(msg, "\n", " "); // we want one-line error messages
+ chat.mText += " (" + msg + ")";
- std::string msg = LLTrans::getString("TranslationFailed", LLSD().with("[REASON]", err_msg));
- LLStringUtil::replaceString(msg, "\n", " "); // we want one-line error messages
- m_chat.mText += " (" + msg + ")";
+ LLNotificationsUI::LLNotificationManager::instance().onChat(chat, toastArgs);
+}
- LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs);
- }
-private:
- LLChat m_chat;
- std::string m_origMesg;
- LLSD m_toastArgs;
-};
void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
{
LLChat chat;
@@ -3771,8 +3733,10 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
const std::string from_lang = ""; // leave empty to trigger autodetect
const std::string to_lang = LLTranslate::getTranslateLanguage();
- LLTranslate::TranslationReceiverPtr result = ChatTranslationReceiver::build(from_lang, to_lang, mesg, chat, args);
- LLTranslate::translateMessage(result, from_lang, to_lang, mesg);
+ LLTranslate::translateMessage(from_lang, to_lang, mesg,
+ boost::bind(&translateSuccess, chat, args, mesg, from_lang, _1, _2),
+ boost::bind(&translateFailure, chat, args, _1, _2));
+
}
else
{
@@ -3991,6 +3955,13 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
return;
}
+
+ if (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE)
+ {
+ // Server either ignored teleport cancel message or did not receive it in time.
+ // This message can't be ignored since teleport is complete at server side
+ gAgent.restoreCanceledTeleportRequest();
+ }
// Teleport is finished; it can't be cancelled now.
gViewerWindow->setProgressCancelButtonVisible(FALSE);
@@ -5606,6 +5577,10 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
bool you_paid_someone = (source_id == gAgentID);
if (you_paid_someone)
{
+ if(!gSavedSettings.getBOOL("NotifyMoneySpend"))
+ {
+ return;
+ }
args["NAME"] = dest_slurl;
is_name_group = is_dest_group;
name_id = dest_id;
@@ -5638,10 +5613,15 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
}
}
final_args["MESSAGE"] = message;
+ payload["dest_id"] = dest_id;
notification = success ? "PaymentSent" : "PaymentFailure";
}
else {
// ...someone paid you
+ if(!gSavedSettings.getBOOL("NotifyMoneyReceived"))
+ {
+ return;
+ }
args["NAME"] = source_slurl;
is_name_group = is_source_group;
name_id = source_id;
@@ -6357,21 +6337,22 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp
BOOL caution = FALSE;
S32 count = 0;
std::string perms;
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
+ BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS)
{
- if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i])
+ if ((orig_questions & script_perm.permbit)
+ && script_perm.caution)
{
count++;
caution = TRUE;
// add a comma before the permission description if it is not the first permission
// added to the list or the last permission to check
- if ((count > 1) && (i < SCRIPT_PERMISSION_EOF))
+ if (count > 1)
{
perms.append(", ");
}
- perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i]));
+ perms.append(LLTrans::getString(script_perm.question));
}
}
@@ -6476,17 +6457,14 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
if (!region)
return false;
- std::string lookup_url=region->getCapability("ExperiencePreferences");
- if(lookup_url.empty())
- return false;
- LLSD permission;
- LLSD data;
- permission["permission"]="Block";
+ LLExperienceCache::instance().setExperiencePermission(experience, std::string("Block"), LLExperienceCache::ExperienceGetFn_t());
- data[experience.asString()]=permission;
- LLHTTPClient::put(lookup_url, data, NULL);
- data["experience"]=experience;
- LLEventPumps::instance().obtain("experience_permission").post(data);
+ LLSD permission;
+ LLSD data;
+ permission["permission"] = "Block";
+ data[experience.asString()] = permission;
+ data["experience"] = experience;
+ LLEventPumps::instance().obtain("experience_permission").post(data);
}
}
return false;
@@ -6603,27 +6581,27 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
std::string script_question;
if (questions)
{
- BOOL caution = FALSE;
+ bool caution = false;
S32 count = 0;
LLSD args;
args["OBJECTNAME"] = object_name;
args["NAME"] = LLCacheName::cleanFullName(owner_name);
S32 known_questions = 0;
- BOOL has_not_only_debit = questions ^ LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_DEBIT];
+ bool has_not_only_debit = questions ^ SCRIPT_PERMISSIONS[SCRIPT_PERMISSION_DEBIT].permbit;
// check the received permission flags against each permission
- for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
+ BOOST_FOREACH(script_perm_t script_perm, SCRIPT_PERMISSIONS)
{
- if (questions & LSCRIPTRunTimePermissionBits[i])
+ if (questions & script_perm.permbit)
{
count++;
- known_questions |= LSCRIPTRunTimePermissionBits[i];
+ known_questions |= script_perm.permbit;
// check whether permission question should cause special caution dialog
- caution |= (SCRIPT_QUESTION_IS_CAUTION[i]);
+ caution |= (script_perm.caution);
- if (("ScriptTakeMoney" == SCRIPT_QUESTIONS[i]) && has_not_only_debit)
+ if (("ScriptTakeMoney" == script_perm.question) && has_not_only_debit)
continue;
- script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "\n";
+ script_question += " " + LLTrans::getString(script_perm.question) + "\n";
}
}
@@ -6661,7 +6639,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
else if(experienceid.notNull())
{
payload["experience"]=experienceid;
- LLExperienceCache::get(experienceid, boost::bind(process_script_experience_details, _1, args, payload));
+ LLExperienceCache::instance().get(experienceid, boost::bind(process_script_experience_details, _1, args, payload));
return;
}
@@ -7429,7 +7407,7 @@ void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool
args["URL"] = load_url_info["url"].asString();
args["MESSAGE"] = load_url_info["message"].asString();;
args["OBJECTNAME"] = load_url_info["object_name"].asString();
- args["NAME"] = owner_name;
+ args["NAME_SLURL"] = LLSLURL(is_group ? "group" : "agent", id, "about").getSLURLString();
LLNotificationsUtil::add("LoadWebPage", args, load_url_info);
}