diff options
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r-- | indra/newview/llimview.cpp | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index a4e356f6a9..f0e2f45db3 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -114,76 +114,84 @@ static void on_avatar_name_cache_toast(const LLUUID& agent_id, LLNotificationsUtil::add("IMToast", args, LLSD(), boost::bind(&LLFloaterIMContainer::showConversation, LLFloaterIMContainer::getInstance(), msg["session_id"].asUUID())); } -void toast_callback(const LLSD& msg){ - // do not show toast in do not disturb mode or it goes from agent - if (gAgent.isDoNotDisturb() || gAgent.getID() == msg["from_id"]) - { - return; - } +void on_new_message(const LLSD& msg) +{ + std::string action; + LLUUID participant_id = msg["from_id"].asUUID(); + LLUUID session_id = msg["session_id"]; + LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(session_id); - // Skip toasting if we have open window of IM with this session id - LLFloaterIMSession* open_im_floater = LLFloaterIMSession::findInstance(msg["session_id"]); - if ( - open_im_floater - && open_im_floater->isInVisibleChain() - && open_im_floater->hasFocus() - && !open_im_floater->isMinimized() - && !(open_im_floater->getHost() - && open_im_floater->getHost()->isMinimized()) - ) + // determine action for this session + if (session_id.isNull()) { - return; + action = gSavedSettings.getString("NotificationNearbyChatOptions"); } - - // Skip toasting for system messages - if (msg["from_id"].asUUID() == LLUUID::null) - { - return; - } - - // *NOTE Skip toasting if the user disable it in preferences/debug settings ~Alexandrea - LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession( - msg["session_id"]); - - - //Ignore P2P Friend/Non-Friend toasts - if(session->isP2PSessionType()) + else if(session->isP2PSessionType()) { - //Ignores non-friends - if((LLAvatarTracker::instance().getBuddyInfo(msg["from_id"]) == NULL) - && (gSavedSettings.getString("NotificationNonFriendIMOptions") != "toast")) + if (LLAvatarTracker::instance().isBuddy(msg["from_id"].asUUID())) { - return; + action = gSavedSettings.getString("NotificationFriendIMOptions"); } - //Ignores friends - else if(gSavedSettings.getString("NotificationFriendIMOptions") != "toast") + else { - return; + action = gSavedSettings.getString("NotificationNonFriendIMOptions"); } } - //Ignore Ad Hoc Toasts - else if(session->isAdHocSessionType() - && (gSavedSettings.getString("NotificationConferenceIMOptions") != "toast")) + else if(session->isAdHocSessionType()) { - return; + action = gSavedSettings.getString("NotificationConferenceIMOptions"); } - //Ignore Group Toasts - else if(session->isGroupSessionType() - && (gSavedSettings.getString("NotificationGroupChatOptions") != "toast")) + else if(session->isGroupSessionType()) { - return; + action = gSavedSettings.getString("NotificationGroupChatOptions"); } - //Show toast - LLAvatarNameCache::get(msg["from_id"].asUUID(), - boost::bind(&on_avatar_name_cache_toast, - _1, _2, msg)); + // do not show notification in "do not disturb" mode or it goes from agent + if (gAgent.isDoNotDisturb() || gAgent.getID() == participant_id) + { + return; + } + + if ("toast" == action) + { + // Skip toasting if we have open window of IM with this session id + LLFloaterIMSession* open_im_floater = LLFloaterIMSession::findInstance(msg["session_id"]); + if ( + open_im_floater + && open_im_floater->isInVisibleChain() + && open_im_floater->hasFocus() + && !open_im_floater->isMinimized() + && !(open_im_floater->getHost() + && open_im_floater->getHost()->isMinimized()) + ) + { + return; + } + + // Skip toasting for system messages + if (participant_id.isNull()) + { + return; + } + + //Show toast + LLAvatarNameCache::get(participant_id, boost::bind(&on_avatar_name_cache_toast, _1, _2, msg)); + } + else if ("flash" == action) + { + LLFloaterIMContainer* im_box = LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container"); + if (im_box) + { + im_box->flashConversationItemWidget(session_id, true); // flashing of the conversation's item + } + gToolBarView->flashCommand(LLCommandId("chat"), true); // flashing of the FUI button "Chat" + } } LLIMModel::LLIMModel() { addNewMsgCallback(boost::bind(&LLFloaterIMSession::newIMCallback, _1)); - addNewMsgCallback(boost::bind(&toast_callback, _1)); + addNewMsgCallback(boost::bind(&on_new_message, _1)); } LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string& name, const EInstantMessage& type, const LLUUID& other_participant_id, const uuid_vec_t& ids, bool voice, bool has_offline_msg) |