summaryrefslogtreecommitdiff
path: root/indra/newview/llimprocessing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llimprocessing.cpp')
-rw-r--r--indra/newview/llimprocessing.cpp125
1 files changed, 80 insertions, 45 deletions
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index e3705e82b9..1e43e4ea3a 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -29,6 +29,7 @@
#include "llimprocessing.h"
#include "llagent.h"
+#include "llappviewer.h"
#include "llavatarnamecache.h"
#include "llfirstuse.h"
#include "llfloaterreg.h"
@@ -61,6 +62,8 @@
#pragma warning (disable:4702)
#endif
+extern void on_new_message(const LLSD& msg);
+
// Strip out "Resident" for display, but only if the message came from a user
// (rather than a script)
static std::string clean_name_from_im(const std::string& name, EInstantMessage type)
@@ -447,7 +450,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
|| (dialog == IM_FROM_TASK && LLMuteList::getInstance()->isMuted(session_id));
BOOL is_owned_by_me = FALSE;
BOOL is_friend = (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL) ? false : true;
- BOOL accept_im_from_only_friend = gSavedSettings.getBOOL("VoiceCallsFriendsOnly");
+ BOOL accept_im_from_only_friend = gSavedPerAccountSettings.getBOOL("VoiceCallsFriendsOnly");
BOOL is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT &&
LLMuteList::getInstance()->isLinden(name);
@@ -854,41 +857,41 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
}
else // IM_TASK_INVENTORY_OFFERED
{
- if (offline == IM_OFFLINE && session_id.isNull() && aux_id.notNull() && binary_bucket_size > sizeof(S8)* 5)
+ if (sizeof(S8) == binary_bucket_size)
{
- // cap received offline message
- std::string str_bucket = ll_safe_string((char*)binary_bucket, binary_bucket_size);
- typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
- boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
- tokenizer tokens(str_bucket, sep);
- tokenizer::iterator iter = tokens.begin();
-
- info->mType = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
- // Note There is more elements in 'tokens' ...
-
- info->mObjectID = LLUUID::null;
- info->mFromObject = TRUE;
+ info->mType = (LLAssetType::EType) binary_bucket[0];
}
else
{
- if (sizeof(S8) != binary_bucket_size)
- {
- LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL;
- delete info;
- break;
- }
- info->mType = (LLAssetType::EType) binary_bucket[0];
- info->mObjectID = LLUUID::null;
- info->mFromObject = TRUE;
+ /*RIDER*/ // The previous version of the protocol returned the wrong binary bucket... we
+ // still might be able to figure out the type... even though the offer is not retrievable.
+
+ // Should be safe to remove once DRTSIM-451 fully deploys
+ std::string str_bucket(reinterpret_cast<char *>(binary_bucket));
+ std::string str_type(str_bucket.substr(0, str_bucket.find('|')));
+
+ std::stringstream type_convert(str_type);
+
+ S32 type;
+ type_convert >> type;
+
+ // We could try AT_UNKNOWN which would be more accurate, but that causes an auto decline
+ info->mType = static_cast<LLAssetType::EType>(type);
+ // Don't break in the case of a bad binary bucket. Go ahead and show the
+ // accept/decline popup even though it will not do anything.
+ LL_WARNS("Messaging") << "Malformed inventory offer from object, type might be " << info->mType << LL_ENDL;
}
+ info->mObjectID = LLUUID::null;
+ info->mFromObject = TRUE;
}
info->mIM = dialog;
info->mFromID = from_id;
info->mFromGroup = from_group;
- info->mTransactionID = session_id;
info->mFolderID = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(info->mType));
+ info->mTransactionID = session_id.notNull() ? session_id : aux_id;
+
info->mFromName = name;
info->mDesc = message;
info->mHost = sender;
@@ -1027,6 +1030,14 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
}
LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args);
+ if (message != "")
+ {
+ LLSD msg_notify;
+ msg_notify["session_id"] = LLUUID();
+ msg_notify["from_id"] = chat.mFromID;
+ msg_notify["source_type"] = chat.mSourceType;
+ on_new_message(msg_notify);
+ }
}
@@ -1153,7 +1164,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
{
return;
}
- else if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL))
+ else if (gSavedPerAccountSettings.getBOOL("VoiceCallsFriendsOnly") && (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL))
{
return;
}
@@ -1393,10 +1404,8 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
payload["sender"] = sender.getIPandPort();
bool add_notification = true;
- for (LLToastNotifyPanel::instance_iter ti(LLToastNotifyPanel::beginInstances())
- , tend(LLToastNotifyPanel::endInstances()); ti != tend; ++ti)
+ for (auto& panel : LLToastNotifyPanel::instance_snapshot())
{
- LLToastNotifyPanel& panel = *ti;
const std::string& notification_name = panel.getNotificationName();
if (notification_name == "OfferFriendship" && panel.isControlPanelEnabled())
{
@@ -1474,6 +1483,7 @@ void LLIMProcessing::requestOfflineMessages()
static BOOL requested = FALSE;
if (!requested
&& gMessageSystem
+ && !gDisconnected
&& LLMuteList::getInstance()->isLoaded()
&& isAgentAvatarValid()
&& gAgent.getRegion()
@@ -1557,11 +1567,15 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)
return;
}
+ if (!gAgent.getRegion())
+ {
+ LL_WARNS("Messaging") << "Region null while attempting to load messages." << LL_ENDL;
+ return;
+ }
+
LL_INFOS("Messaging") << "Processing offline messages." << LL_ENDL;
- std::vector<U8> data;
- S32 binary_bucket_size = 0;
- LLHost sender = gAgent.getRegion()->getHost();
+ LLHost sender = gAgent.getRegionHost();
LLSD::array_iterator i = messages.beginArray();
LLSD::array_iterator iEnd = messages.endArray();
@@ -1569,12 +1583,30 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)
{
const LLSD &message_data(*i);
- LLVector3 position(message_data["local_x"].asReal(), message_data["local_y"].asReal(), message_data["local_z"].asReal());
- data = message_data["binary_bucket"].asBinary();
- binary_bucket_size = data.size(); // message_data["count"] always 0
- U32 parent_estate_id = message_data.has("parent_estate_id") ? message_data["parent_estate_id"].asInteger() : 1; // 1 - IMMainland
+ /* RIDER: Many fields in this message are using a '_' rather than the standard '-'. This
+ * should be changed but would require tight coordination with the simulator.
+ */
+ LLVector3 position;
+ if (message_data.has("position"))
+ {
+ position.setValue(message_data["position"]);
+ }
+ else
+ {
+ position.set(message_data["local_x"].asReal(), message_data["local_y"].asReal(), message_data["local_z"].asReal());
+ }
+
+ std::vector<U8> bin_bucket;
+ if (message_data.has("binary_bucket"))
+ {
+ bin_bucket = message_data["binary_bucket"].asBinary();
+ }
+ else
+ {
+ bin_bucket.push_back(0);
+ }
- // Todo: once dirtsim-369 releases, remove one of the int/str options
+ // Todo: once drtsim-451 releases, remove the string option
BOOL from_group;
if (message_data["from_group"].isInteger())
{
@@ -1585,22 +1617,25 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)
from_group = message_data["from_group"].asString() == "Y";
}
- LLIMProcessing::processNewMessage(message_data["from_agent_id"].asUUID(),
+
+ LLIMProcessing::processNewMessage(
+ message_data["from_agent_id"].asUUID(),
from_group,
message_data["to_agent_id"].asUUID(),
- IM_OFFLINE,
- (EInstantMessage)message_data["dialog"].asInteger(),
- LLUUID::null, // session id, since there is none we can only use frienship/group invite caps
- message_data["timestamp"].asInteger(),
+ message_data.has("offline") ? static_cast<U8>(message_data["offline"].asInteger()) : IM_OFFLINE,
+ static_cast<EInstantMessage>(message_data["dialog"].asInteger()),
+ message_data["transaction-id"].asUUID(),
+ static_cast<U32>(message_data["timestamp"].asInteger()),
message_data["from_agent_name"].asString(),
message_data["message"].asString(),
- parent_estate_id,
+ static_cast<U32>((message_data.has("parent_estate_id")) ? message_data["parent_estate_id"].asInteger() : 1), // 1 - IMMainland
message_data["region_id"].asUUID(),
position,
- &data[0],
- binary_bucket_size,
+ bin_bucket.data(),
+ bin_bucket.size(),
sender,
- message_data["asset_id"].asUUID()); // not necessarily an asset
+ message_data["asset_id"].asUUID());
+
}
}