diff options
Diffstat (limited to 'indra/newview/llnotificationtiphandler.cpp')
-rw-r--r-- | indra/newview/llnotificationtiphandler.cpp | 109 |
1 files changed, 44 insertions, 65 deletions
diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp index c55c8d6221..94612975a2 100644 --- a/indra/newview/llnotificationtiphandler.cpp +++ b/indra/newview/llnotificationtiphandler.cpp @@ -2,31 +2,25 @@ * @file llnotificationtiphandler.cpp * @brief Notification Handler Class for Notification Tips * - * $LicenseInfo:firstyear=2000&license=viewergpl$ - * - * Copyright (c) 2000-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2000&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -40,41 +34,11 @@ #include "lltoastnotifypanel.h" #include "llviewercontrol.h" #include "llviewerwindow.h" +#include "llnotificationmanager.h" +#include "llpaneltiptoast.h" using namespace LLNotificationsUI; -class LLOnalineStatusToast : public LLToastPanel -{ -public: - - struct Params - { - LLNotificationPtr notification; - LLUUID avatar_id; - std::string message; - - Params() {} - }; - - LLOnalineStatusToast(Params& p) : LLToastPanel(p.notification) - { - LLUICtrlFactory::getInstance()->buildPanel(this, "panel_online_status.xml"); - - childSetValue("avatar_icon", p.avatar_id); - childSetValue("message", p.message); - - if (p.notification->getPayload().has("respond_on_mousedown") - && p.notification->getPayload()["respond_on_mousedown"] ) - { - setMouseDownCallback(boost::bind(&LLNotification::respond, p.notification, - p.notification->getResponseTemplate())); - } - - // set line max count to 2 in case of a very long name - snapToMessageHeight(getChild<LLTextBox>("message"), 2); - } -}; - //-------------------------------------------------------------------------- LLTipHandler::LLTipHandler(e_notification_type type, const LLSD& id) { @@ -82,6 +46,10 @@ LLTipHandler::LLTipHandler(e_notification_type type, const LLSD& id) // Getting a Channel for our notifications mChannel = LLChannelManager::getInstance()->createNotificationChannel(); + + LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel); + if(channel) + channel->setOnRejectToastCallback(boost::bind(&LLTipHandler::onRejectToast, this, _1)); } //-------------------------------------------------------------------------- @@ -132,11 +100,16 @@ bool LLTipHandler::processNotification(const LLSD& notify) } } + std::string session_name = notification->getPayload()["SESSION_NAME"]; const std::string name = notification->getSubstitutions()["NAME"]; + if (session_name.empty()) + { + session_name = name; + } LLUUID from_id = notification->getPayload()["from_id"]; if (LLHandlerUtil::canLogToIM(notification)) { - LLHandlerUtil::logToIM(IM_NOTHING_SPECIAL, name, name, + LLHandlerUtil::logToIM(IM_NOTHING_SPECIAL, session_name, name, notification->getMessage(), from_id, from_id); } @@ -145,20 +118,14 @@ bool LLTipHandler::processNotification(const LLSD& notify) LLHandlerUtil::spawnIMSession(name, from_id); } - LLToastPanel* notify_box = NULL; - if("FriendOffline" == notification->getName() || "FriendOnline" == notification->getName()) - { - LLOnalineStatusToast::Params p; - p.notification = notification; - p.message = notification->getMessage(); - p.avatar_id = notification->getPayload()["FROM_ID"]; - notify_box = new LLOnalineStatusToast(p); - } - else + // don't spawn toast for inventory accepted/declined offers if respective IM window is open (EXT-5909) + if (!LLHandlerUtil::canSpawnToast(notification)) { - notify_box = new LLToastNotifyPanel(notification); + return true; } + LLToastPanel* notify_box = LLToastPanel::buidPanelFromNotification(notification); + LLToast::Params p; p.notif_id = notification->getID(); p.notification = notification; @@ -167,6 +134,8 @@ bool LLTipHandler::processNotification(const LLSD& notify) p.is_tip = true; p.can_be_stored = false; + removeExclusiveNotifications(notification); + LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel); if(channel) channel->addToast(p); @@ -185,4 +154,14 @@ void LLTipHandler::onDeleteToast(LLToast* toast) //-------------------------------------------------------------------------- +void LLTipHandler::onRejectToast(const LLUUID& id) +{ + LLNotificationPtr notification = LLNotifications::instance().find(id); + if (notification + && LLNotificationManager::getInstance()->getHandlerForNotification( + notification->getType()) == this) + { + LLNotifications::instance().cancel(notification); + } +} |