From 2d9285cddb4a48fb766b21fac2705c8873e15f93 Mon Sep 17 00:00:00 2001 From: Gilbert Gonzales Date: Fri, 16 Nov 2012 18:53:05 -0800 Subject: CHUI-529: Now the conversations floater will appear when the chat preference is set for friend, non-friend, conference, group and nearby chat. --- indra/newview/llfloaterimnearbychathandler.cpp | 50 ++++++---- indra/newview/llimview.cpp | 104 +++++++++++++-------- .../default/xui/en/panel_preferences_chat.xml | 20 ++++ 3 files changed, 116 insertions(+), 58 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index ab81b85d04..2d8a6d46fe 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -41,6 +41,7 @@ #include "llfloaterreg.h"//for LLFloaterReg::getTypedInstance #include "llviewerwindow.h"//for screen channel position #include "llfloaterimnearbychat.h" +#include "llfloaterimcontainer.h" #include "llrootview.h" #include "lllayoutstack.h" @@ -283,12 +284,6 @@ bool LLFloaterIMNearbyChatScreenChannel::createPoolToast() void LLFloaterIMNearbyChatScreenChannel::addChat(LLSD& chat) { - //Ignore Nearby Toasts - if(gSavedSettings.getString("NotificationNearbyChatOptions") != "toast") - { - return; - } - //look in pool. if there is any message if(mStopProcessing) return; @@ -606,19 +601,36 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, toast_msg = chat_msg.mText; } - // Add a nearby chat toast. - LLUUID id; - id.generate(); - chat["id"] = id; - std::string r_color_name = "White"; - F32 r_color_alpha = 1.0f; - LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha); - - chat["text_color"] = r_color_name; - chat["color_alpha"] = r_color_alpha; - chat["font_size"] = (S32)LLViewerChat::getChatFontSize() ; - chat["message"] = toast_msg; - channel->addChat(chat); + + //Will show toast when chat preference is set + if(gSavedSettings.getString("NotificationNearbyChatOptions") == "toast") + { + // Add a nearby chat toast. + LLUUID id; + id.generate(); + chat["id"] = id; + std::string r_color_name = "White"; + F32 r_color_alpha = 1.0f; + LLViewerChat::getChatColor( chat_msg, r_color_name, r_color_alpha); + + chat["text_color"] = r_color_name; + chat["color_alpha"] = r_color_alpha; + chat["font_size"] = (S32)LLViewerChat::getChatFontSize() ; + chat["message"] = toast_msg; + channel->addChat(chat); + } + //Will show Conversations floater when chat preference is set + else if(gSavedSettings.getString("NotificationNearbyChatOptions") == "openconversations") + { + LLFloaterIMContainer * floaterIMContainer = LLFloaterIMContainer::getInstance(); + + if(floaterIMContainer) + { + floaterIMContainer->setVisible(TRUE); + floaterIMContainer->setFrontmost(TRUE); + } + } + } } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 818de4eaf4..106811b7e0 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -112,6 +112,55 @@ 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())); } +//Will return true if the preference is allowed (user configures these preferences via 'Chat Preference' Dialog +bool ignoreNotification(const LLSD& msg, const char * preferenceString) +{ + //Get the session so we can find out the type of session + LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession( + msg["session_id"]); + + const LLRelationship * relationship; + + // Skip system messages + if (msg["from_id"].asUUID() == LLUUID::null) + { + return true; + } + + //Ignore P2P Friend/Non-Friend Notification + if(session->isP2PSessionType()) + { + relationship = LLAvatarTracker::instance().getBuddyInfo(msg["from_id"]); + + //Ignores non-friends + if(relationship == NULL + && (gSavedSettings.getString("NotificationNonFriendIMOptions") != preferenceString)) + { + return true; + } + //Ignores friends + else if(relationship + && gSavedSettings.getString("NotificationFriendIMOptions") != preferenceString) + { + return true; + } + } + //Ignore Ad Hoc Notification + else if(session->isAdHocSessionType() + && (gSavedSettings.getString("NotificationConferenceIMOptions") != preferenceString)) + { + return true; + } + //Ignore Group Notification + else if(session->isGroupSessionType() + && (gSavedSettings.getString("NotificationGroupChatOptions") != preferenceString)) + { + return true; + } + + return false; +} + 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"]) @@ -133,55 +182,32 @@ void toast_callback(const LLSD& msg){ return; } - // 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()) - { - //Ignores non-friends - if((LLAvatarTracker::instance().getBuddyInfo(msg["from_id"]) == NULL) - && (gSavedSettings.getString("NotificationNonFriendIMOptions") != "toast")) - { - return; - } - //Ignores friends - else if(gSavedSettings.getString("NotificationFriendIMOptions") != "toast") - { - return; - } - } - //Ignore Ad Hoc Toasts - else if(session->isAdHocSessionType() - && (gSavedSettings.getString("NotificationConferenceIMOptions") != "toast")) + //Show toast + if(ignoreNotification(msg, "toast") == false) { - return; + LLAvatarNameCache::get(msg["from_id"].asUUID(), + boost::bind(&on_avatar_name_cache_toast, + _1, _2, msg)); } - //Ignore Group Toasts - else if(session->isGroupSessionType() - && (gSavedSettings.getString("NotificationGroupChatOptions") != "toast")) +} + +void open_conversations_callback(const LLSD& msg) +{ + LLFloaterIMContainer * floaterIMContainer = LLFloaterIMContainer::getInstance(); + + if(floaterIMContainer + && ignoreNotification(msg, "openconversations") == false) { - return; + floaterIMContainer->setVisible(TRUE); + floaterIMContainer->setFrontmost(TRUE); } - - //Show toast - LLAvatarNameCache::get(msg["from_id"].asUUID(), - boost::bind(&on_avatar_name_cache_toast, - _1, _2, msg)); } LLIMModel::LLIMModel() { addNewMsgCallback(boost::bind(&LLFloaterIMSession::newIMCallback, _1)); addNewMsgCallback(boost::bind(&toast_callback, _1)); + addNewMsgCallback(boost::bind(&open_conversations_callback, _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) diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml index 712e8bff7f..0c94b6b223 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml @@ -134,6 +134,10 @@ top_delta="-6" name="FriendIMOptions" width="223"> + + + + + Date: Mon, 26 Nov 2012 19:12:04 -0800 Subject: CHUI-529: Post code review changes. When showing a floater using LLFloater::showInstance() instead of setVisibleAndFrontmost(). Also made setVisibleAndFrontmost() public since both setVisible and setFrontmost are public functions. --- indra/newview/llfloaterimnearbychathandler.cpp | 8 +------- indra/newview/llimview.cpp | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index 2d8a6d46fe..d9c461e836 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -622,13 +622,7 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, //Will show Conversations floater when chat preference is set else if(gSavedSettings.getString("NotificationNearbyChatOptions") == "openconversations") { - LLFloaterIMContainer * floaterIMContainer = LLFloaterIMContainer::getInstance(); - - if(floaterIMContainer) - { - floaterIMContainer->setVisible(TRUE); - floaterIMContainer->setFrontmost(TRUE); - } + LLFloaterReg::showInstance("im_container"); } } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index fc6be2cd97..581043a3d0 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -191,13 +191,7 @@ void on_new_message(const LLSD& msg) } else if("openconversations" == action) { - LLFloaterIMContainer * floaterIMContainer = LLFloaterIMContainer::getInstance(); - - if(floaterIMContainer) - { - floaterIMContainer->setVisible(TRUE); - floaterIMContainer->setFrontmost(TRUE); - } + LLFloaterReg::showInstance("im_container"); } } -- cgit v1.2.3