summaryrefslogtreecommitdiff
path: root/indra/newview/llnotificationofferhandler.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-03-27 22:56:02 -0700
committerRichard Linden <none@none>2012-03-27 22:56:02 -0700
commit1ea65f0285d7022ce20ef84d4e35e3c94bcb3fbd (patch)
tree5af1e50737b6a96f7a05ba6b5f5c5ac3c0f551b3 /indra/newview/llnotificationofferhandler.cpp
parentb187aeb8f177bd76e792652e773617beff18b47b (diff)
CHUI-51 WIP notifications routig code cleanup
phase 1, removal of most of llnotificationhandler
Diffstat (limited to 'indra/newview/llnotificationofferhandler.cpp')
-rw-r--r--indra/newview/llnotificationofferhandler.cpp172
1 files changed, 81 insertions, 91 deletions
diff --git a/indra/newview/llnotificationofferhandler.cpp b/indra/newview/llnotificationofferhandler.cpp
index 68fd65be0f..8010417d43 100644
--- a/indra/newview/llnotificationofferhandler.cpp
+++ b/indra/newview/llnotificationofferhandler.cpp
@@ -40,17 +40,16 @@
using namespace LLNotificationsUI;
//--------------------------------------------------------------------------
-LLOfferHandler::LLOfferHandler(e_notification_type type, const LLSD& id)
+LLOfferHandler::LLOfferHandler()
+: LLSysHandler("Offer", "offer")
{
- mType = type;
-
// Getting a Channel for our notifications
mChannel = LLChannelManager::getInstance()->createNotificationChannel();
mChannel->setControlHovering(true);
LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel);
if(channel)
- channel->setOnRejectToastCallback(boost::bind(&LLOfferHandler::onRejectToast, this, _1));
+ channel->addOnRejectToastCallback(boost::bind(&LLOfferHandler::onRejectToast, this, _1));
}
//--------------------------------------------------------------------------
@@ -67,126 +66,118 @@ void LLOfferHandler::initChannel()
}
//--------------------------------------------------------------------------
-bool LLOfferHandler::processNotification(const LLSD& notify)
+bool LLOfferHandler::processNotification(const LLNotificationPtr& notification)
{
if(!mChannel)
{
return false;
}
- LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID());
-
- if(!notification)
- return false;
-
// arrange a channel on a screen
if(!mChannel->getVisible())
{
initChannel();
}
- if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change")
- {
+ bool add_notif_to_im = notification->canLogToIM() && notification->hasFormElements();
+ if( notification->getPayload().has("give_inventory_notification")
+ && !notification->getPayload()["give_inventory_notification"] )
+ {
+ // This is an original inventory offer, so add a script floater
+ LLScriptFloaterManager::instance().onAddNotification(notification->getID());
+ }
+ else
+ {
+ notification->setReusable(add_notif_to_im);
- if( notification->getPayload().has("give_inventory_notification")
- && !notification->getPayload()["give_inventory_notification"] )
- {
- // This is an original inventory offer, so add a script floater
- LLScriptFloaterManager::instance().onAddNotification(notification->getID());
- }
- else
+ LLUUID session_id;
+ if (add_notif_to_im)
{
- notification->setReusable(LLHandlerUtil::isNotificationReusable(notification));
+ const std::string name = LLHandlerUtil::getSubstitutionName(notification);
- LLUUID session_id;
- if (LLHandlerUtil::canSpawnIMSession(notification))
- {
- const std::string name = LLHandlerUtil::getSubstitutionName(notification);
+ LLUUID from_id = notification->getPayload()["from_id"];
- LLUUID from_id = notification->getPayload()["from_id"];
+ session_id = LLHandlerUtil::spawnIMSession(name, from_id);
+ }
- session_id = LLHandlerUtil::spawnIMSession(name, from_id);
- }
+ if (add_notif_to_im)
+ {
+ LLHandlerUtil::addNotifPanelToIM(notification);
+ }
- bool show_toast = LLHandlerUtil::canSpawnToast(notification);
- bool add_notid_to_im = LLHandlerUtil::canAddNotifPanelToIM(notification);
- if (add_notid_to_im)
+ if (notification->getPayload().has("SUPPRESS_TOAST")
+ && notification->getPayload()["SUPPRESS_TOAST"])
+ {
+ LLNotificationsUtil::cancel(notification);
+ }
+ else if(!notification->canLogToIM() || !LLHandlerUtil::isIMFloaterOpened(notification))
+ {
+ LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);
+ // don't close notification on panel destroy since it will be used by IM floater
+ notify_box->setCloseNotificationOnDestroy(!add_notif_to_im);
+ LLToast::Params p;
+ p.notif_id = notification->getID();
+ p.notification = notification;
+ p.panel = notify_box;
+ p.on_delete_toast = boost::bind(&LLOfferHandler::onDeleteToast, this, _1);
+ // we not save offer notifications to the syswell floater that should be added to the IM floater
+ p.can_be_stored = !add_notif_to_im;
+
+ LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel);
+ if(channel)
+ channel->addToast(p);
+
+ // if we not add notification to IM - add it to notification well
+ if (!add_notif_to_im)
{
- LLHandlerUtil::addNotifPanelToIM(notification);
+ // send a signal to the counter manager
+ mNewNotificationSignal();
}
+ }
- if (notification->getPayload().has("SUPPRESS_TOAST")
- && notification->getPayload()["SUPPRESS_TOAST"])
- {
- LLNotificationsUtil::cancel(notification);
- }
- else if(show_toast)
+ if (notification->canLogToIM())
+ {
+ // log only to file if notif panel can be embedded to IM and IM is opened
+ if (add_notif_to_im && LLHandlerUtil::isIMFloaterOpened(notification))
{
- LLToastNotifyPanel* notify_box = new LLToastNotifyPanel(notification);
- // don't close notification on panel destroy since it will be used by IM floater
- notify_box->setCloseNotificationOnDestroy(!add_notid_to_im);
- LLToast::Params p;
- p.notif_id = notification->getID();
- p.notification = notification;
- p.panel = notify_box;
- p.on_delete_toast = boost::bind(&LLOfferHandler::onDeleteToast, this, _1);
- // we not save offer notifications to the syswell floater that should be added to the IM floater
- p.can_be_stored = !add_notid_to_im;
-
- LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel);
- if(channel)
- channel->addToast(p);
-
- // if we not add notification to IM - add it to notification well
- if (!add_notid_to_im)
- {
- // send a signal to the counter manager
- mNewNotificationSignal();
- }
+ LLHandlerUtil::logToIMP2P(notification, true);
}
-
- if (LLHandlerUtil::canLogToIM(notification))
+ else
{
- // log only to file if notif panel can be embedded to IM and IM is opened
- if (add_notid_to_im && LLHandlerUtil::isIMFloaterOpened(notification))
- {
- LLHandlerUtil::logToIMP2P(notification, true);
- }
- else
- {
- LLHandlerUtil::logToIMP2P(notification);
- }
+ LLHandlerUtil::logToIMP2P(notification);
}
}
}
- else if (notify["sigtype"].asString() == "delete")
+
+ return false;
+}
+
+/*virtual*/ void LLOfferHandler::onDelete(LLNotificationPtr notification)
+{
+ if( notification->getPayload().has("give_inventory_notification")
+ && !notification->getPayload()["give_inventory_notification"] )
+ {
+ // Remove original inventory offer script floater
+ LLScriptFloaterManager::instance().onRemoveNotification(notification->getID());
+ }
+ else
{
- if( notification->getPayload().has("give_inventory_notification")
- && !notification->getPayload()["give_inventory_notification"] )
+ if (notification->canLogToIM()
+ && notification->hasFormElements()
+ && !LLHandlerUtil::isIMFloaterOpened(notification))
{
- // Remove original inventory offer script floater
- LLScriptFloaterManager::instance().onRemoveNotification(notification->getID());
- }
- else
- {
- if (LLHandlerUtil::canAddNotifPanelToIM(notification)
- && !LLHandlerUtil::isIMFloaterOpened(notification))
- {
- LLHandlerUtil::decIMMesageCounter(notification);
- }
- mChannel->killToastByNotificationID(notification->getID());
+ LLHandlerUtil::decIMMesageCounter(notification);
}
+ mChannel->killToastByNotificationID(notification->getID());
}
-
- return false;
}
//--------------------------------------------------------------------------
void LLOfferHandler::onDeleteToast(LLToast* toast)
{
- if (!LLHandlerUtil::canAddNotifPanelToIM(toast->getNotification()))
+ if (!toast->getNotification()->canLogToIM() || !toast->getNotification()->hasFormElements())
{
// send a signal to the counter manager
mDelNotificationSignal();
@@ -202,11 +193,10 @@ void LLOfferHandler::onRejectToast(LLUUID& id)
{
LLNotificationPtr notification = LLNotifications::instance().find(id);
- if (notification
- && LLNotificationManager::getInstance()->getHandlerForNotification(
- notification->getType()) == this
- // don't delete notification since it may be used by IM floater
- && !LLHandlerUtil::canAddNotifPanelToIM(notification))
+ if (notification
+ && mItems.find(notification) != mItems.end()
+ // don't delete notification since it may be used by IM floater
+ && (!notification->canLogToIM() || !notification->hasFormElements()))
{
LLNotifications::instance().cancel(notification);
}