// Add a message to a session. void LLIMMgr::addMessage( const LLUUID& session_id, const LLUUID& target_id, const std::string& from, const std::string& msg, const std::string& session_name, EInstantMessage dialog, U32 parent_estate_id, const LLUUID& region_id, const LLVector3& position, bool link_name) // If this is true, then we insert the name and link it to a profile { LLUUID other_participant_id = target_id; // don't process muted IMs if (LLMuteList::getInstance()->isMuted( other_participant_id, LLMute::flagTextChat) && !LLMuteList::getInstance()->isLinden(from)) { return; } LLUUID new_session_id = session_id; if (new_session_id.isNull()) { //no session ID...compute new one new_session_id = computeSessionID(dialog, other_participant_id); } LLFloaterIMPanel* floater = findFloaterBySession(new_session_id); if (!floater) { floater = findFloaterBySession(other_participant_id); if (floater) { LL_INFOS() << "found the IM session " << new_session_id << " by participant " << other_participant_id << LL_ENDL; } } if (LLVOAvatar* from_avatar = find_avatar_from_object(target_id)) from_avatar->mIdleTimer.reset(); // Not idle, message sent to somewhere // create IM window as necessary if(!floater) { // Return now if we're blocking this group's chat or conferences if (gAgent.isInGroup(session_id) ? getIgnoreGroup(session_id) : dialog != IM_NOTHING_SPECIAL && dialog != IM_SESSION_P2P_INVITE && block_conference(other_participant_id)) return; std::string name = (session_name.size() > 1) ? session_name : from; floater = createFloater(new_session_id, other_participant_id, name, dialog); // When we get a new IM, and if you are a god, display a bit // of information about the source. This is to help liaisons // when answering questions. if(gAgent.isGodlike()) { std::ostringstream bonus_info; bonus_info << LLTrans::getString("***")+ " "+ LLTrans::getString("IMParentEstate") + LLTrans::getString(":") + " " << parent_estate_id << ((parent_estate_id == 1) ? LLTrans::getString(",") + LLTrans::getString("IMMainland") : "") << ((parent_estate_id == 5) ? LLTrans::getString(",") + LLTrans::getString ("IMTeen") : ""); // once we have web-services (or something) which returns // information about a region id, we can print this out // and even have it link to map-teleport or something. //<< "*** region_id: " << region_id << std::endl //<< "*** position: " << position << std::endl; floater->addHistoryLine(bonus_info.str(), gSavedSettings.getColor4("SystemChatColor")); } make_ui_sound("UISndNewIncomingIMSession"); } // now add message to floater LLColor4 color = agent_chat_color(other_participant_id, from, false); if (dialog == IM_BUSY_AUTO_RESPONSE) { color *= .75f; color += LLColor4::transparent*.25f; } if ( !link_name ) { floater->addHistoryLine(msg,color); // No name to prepend, so just add the message normally } else { if( other_participant_id == session_id ) { // The name can be bogus on InWorldz floater->addHistoryLine(msg, color, true, LLUUID::null, from); } else { // Insert linked name to front of message floater->addHistoryLine(msg, color, true, other_participant_id, from); } } if (!gIMMgr->getFloaterOpen() && floater->getParent() != gFloaterView) { // If the chat floater is closed and not torn off) notify of a new IM mIMUnreadCount++; } }
LLColor4 get_text_color(const LLChat& chat, bool from_im) { LLColor4 text_color; if(chat.mMuted) { static LLCachedControl<bool> color_muted_chat("ColorMutedChat"); if (color_muted_chat) text_color = gSavedSettings.getColor4("AscentMutedColor"); else text_color.setVec(0.8f, 0.8f, 0.8f, 1.f); } else { switch(chat.mSourceType) { case CHAT_SOURCE_SYSTEM: text_color = gSavedSettings.getColor4("SystemChatColor"); break; case CHAT_SOURCE_AGENT: text_color = agent_chat_color(chat.mFromID, chat.mFromName, !from_im); break; case CHAT_SOURCE_OBJECT: if (chat.mChatType == CHAT_TYPE_DEBUG_MSG) { text_color = gSavedSettings.getColor4("ScriptErrorColor"); } else if ( chat.mChatType == CHAT_TYPE_OWNER ) { text_color = gSavedSettings.getColor4("llOwnerSayChatColor"); } else { text_color = gSavedSettings.getColor4("ObjectChatColor"); } break; default: text_color.setToWhite(); } if (!chat.mPosAgent.isExactlyZero()) { LLVector3 pos_agent = gAgent.getPositionAgent(); F32 distance = dist_vec(pos_agent, chat.mPosAgent); if (distance > gAgent.getNearChatRadius()) { // diminish far-off chat text_color.mV[VALPHA] = 0.8f; } } } static const LLCachedControl<bool> sKeywordsChangeColor(gSavedPerAccountSettings, "KeywordsChangeColor", false); if (sKeywordsChangeColor && gAgentID != chat.mFromID && chat.mSourceType != CHAT_SOURCE_SYSTEM && AscentKeyword::hasKeyword(boost::starts_with(chat.mText, chat.mFromName) ? chat.mText.substr(chat.mFromName.length()) : chat.mText, 1)) { static const LLCachedControl<LLColor4> sKeywordsColor(gSavedPerAccountSettings, "KeywordsColor", LLColor4(1.f, 1.f, 1.f, 1.f)); text_color = sKeywordsColor; } return text_color; }