summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r--indra/newview/llviewermessage.cpp97
1 files changed, 87 insertions, 10 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index af0af9cd0e..c8cc813576 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -105,6 +105,7 @@
#include "llpanelplaceprofile.h"
#include <boost/algorithm/string/split.hpp> //
+#include <boost/regex.hpp>
#if LL_WINDOWS // For Windows specific error handler
#include "llwindebug.h" // For the invalid message handler
@@ -272,7 +273,9 @@ void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_
}
else
{
- LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("giving"), amount);
+ LLStringUtil::format_map_t args;
+ args["AMOUNT"] = llformat("%d", amount);
+ LLFloaterBuyCurrency::buyCurrency(LLTrans::getString("giving", args), amount);
}
}
@@ -1081,6 +1084,21 @@ LLOfferInfo::LLOfferInfo(const LLSD& sd)
mHost = LLHost(sd["sender"].asString());
}
+LLOfferInfo::LLOfferInfo(const LLOfferInfo& info)
+{
+ mIM = info.mIM;
+ mFromID = info.mFromID;
+ mFromGroup = info.mFromGroup;
+ mFromObject = info.mFromObject;
+ mTransactionID = info.mTransactionID;
+ mFolderID = info.mFolderID;
+ mObjectID = info.mObjectID;
+ mType = info.mType;
+ mFromName = info.mFromName;
+ mDesc = info.mDesc;
+ mHost = info.mHost;
+}
+
LLSD LLOfferInfo::asLLSD()
{
LLSD sd;
@@ -1572,7 +1590,11 @@ void inventory_offer_handler(LLOfferInfo* info)
}
else // Agent -> Agent Inventory Offer
{
+ p.responder = info;
// Note: sets inventory_offer_callback as the callback
+ // *TODO fix memory leak
+ // inventory_offer_callback() is not invoked if user received notification and
+ // closes viewer(without responding the notification)
p.substitutions(args).payload(payload).functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2));
p.name = "UserGiveItem";
@@ -1730,17 +1752,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
std::string separator_string(": ");
LLSD args;
+ LLSD payload;
switch(dialog)
{
case IM_CONSOLE_AND_CHAT_HISTORY:
- // These are used for system messages, hence don't need the name,
- // as it is always "Second Life".
// *TODO: Translate
args["MESSAGE"] = message;
-
- // Note: don't put the message in the IM history, even though was sent
- // via the IM mechanism.
- LLNotificationsUtil::add("SystemMessageTip",args);
+ payload["SESSION_NAME"] = name;
+ payload["from_id"] = from_id;
+ LLNotificationsUtil::add("IMSystemMessageTip",args, payload);
break;
case IM_NOTHING_SPECIAL:
@@ -1963,7 +1983,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// For requested notices, we don't want to send the popups.
if (dialog != IM_GROUP_NOTICE_REQUESTED)
{
- LLSD payload;
payload["subject"] = subj;
payload["message"] = mes;
payload["sender_name"] = name;
@@ -2294,7 +2313,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
{
LLSD args;
// *TODO: Translate -> [FIRST] [LAST] (maybe)
- args["NAME"] = name;
+ args["NAME_SLURL"] = LLSLURL::buildCommand("agent", from_id, "about");
args["MESSAGE"] = message;
LLSD payload;
payload["from_id"] = from_id;
@@ -3083,7 +3102,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
<< x << ":" << y
<< " current pos " << gAgent.getPositionGlobal()
<< LL_ENDL;
- LLAppViewer::instance()->forceDisconnect("You were sent to an invalid region.");
+ LLAppViewer::instance()->forceDisconnect(LLTrans::getString("SentToInvalidRegion"));
return;
}
@@ -4501,8 +4520,64 @@ void process_money_balance_reply( LLMessageSystem* msg, void** )
payload["from_id"] = from_id;
LLNotificationsUtil::add("PaymentRecived", args, payload);
}
+ //AD *HACK: Parsing incoming string to localize messages that come from server! EXT-5986
+ // It's only a temporarily and ineffective measure. It doesn't affect performance much
+ // because we get here only for specific type of messages, but anyway it is not right to do it!
+ // *TODO: Server-side changes should be made and this code removed.
else
{
+ if(desc.find("You paid")==0)
+ {
+ // Regular expression for message parsing- change it in case of server-side changes.
+ // Each set of parenthesis will later be used to find arguments of message we generate
+ // in the end of this if- (.*) gives us name of money receiver, (\\d+)-amount of money we pay
+ // and ([^$]*)- reason of payment
+ boost::regex expr("You paid (?:.{0}|(.*) )L\\$(\\d+)\\s?([^$]*)\\.");
+ boost::match_results <std::string::const_iterator> matches;
+ if(boost::regex_match(desc, matches, expr))
+ {
+ // Name of full localizable notification string
+ // there are three types of this string- with name of receiver and reason of payment,
+ // without name and without reason (but not simultaneously)
+ // example of string without name - You paid L$100 to create a group.
+ // example of string without reason - You paid Smdby Linden L$100.
+ // example of string with reason and name - You paid Smbdy Linden L$100 for a land access pass.
+ std::string line = "you_paid_ldollars_no_name";
+
+ // arguments of string which will be in notification
+ LLStringUtil::format_map_t str_args;
+
+ // extracting amount of money paid (without L$ symbols). It is always present.
+ str_args["[AMOUNT]"] = std::string(matches[2]);
+
+ // extracting name of person/group you are paying (it may be absent)
+ std::string name = std::string(matches[1]);
+ if(!name.empty())
+ {
+ str_args["[NAME]"] = name;
+ line = "you_paid_ldollars";
+ }
+
+ // extracting reason of payment (it may be absent)
+ std::string reason = std::string(matches[3]);
+ if (reason.empty())
+ {
+ line = "you_paid_ldollars_no_reason";
+ }
+ else
+ {
+ std::string localized_reason;
+ // if we haven't found localized string for reason of payment leave it as it was
+ str_args["[REASON]"] = LLTrans::findString(localized_reason, reason) ? localized_reason : reason;
+ }
+
+ // forming final message string by retrieving localized version from xml
+ // and applying previously found arguments
+ line = LLTrans::getString(line, str_args);
+ args["MESSAGE"] = line;
+ }
+ }
+
LLNotificationsUtil::add("SystemMessage", args);
}
@@ -5489,6 +5564,8 @@ bool handle_lure_callback(const LLSD& notification, const LLSD& response)
args["TO_NAME"] = target_name;
LLSD payload;
+
+ //*TODO please rewrite all keys to the same case, lower or upper
payload["from_id"] = target_id;
payload["SESSION_NAME"] = target_name;
payload["SUPPRESS_TOAST"] = true;