summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llnotifications.cpp8
-rw-r--r--indra/llui/llnotifications.h22
-rw-r--r--indra/newview/lldonotdisturbnotificationstorage.cpp12
-rw-r--r--indra/newview/llimhandler.cpp86
-rw-r--r--indra/newview/llimview.cpp37
-rw-r--r--indra/newview/llnotificationstorage.cpp7
-rwxr-xr-xindra/newview/llviewermessage.cpp3
-rw-r--r--indra/newview/llviewermessage.h1
8 files changed, 124 insertions, 52 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 89fb5ed30c..386345177d 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -475,7 +475,8 @@ LLNotification::LLNotification(const LLSDParamAdapter<Params>& p) :
mIgnored(false),
mResponderObj(NULL),
mId(p.id.isProvided() ? p.id : LLUUID::generateNewID()),
- mOfferFromAgent(p.offer_from_agent)
+ mOfferFromAgent(p.offer_from_agent),
+ mIsDND(p.is_dnd)
{
if (p.functor.name.isChosen())
{
@@ -517,6 +518,11 @@ LLSD LLNotification::asLLSD()
p.expiry = mExpiresAt;
p.priority = mPriority;
+ if(mResponder)
+ {
+ p.functor.responder_sd = mResponder->asLLSD();
+ }
+
if(!mResponseFunctorName.empty())
{
p.functor.name = mResponseFunctorName;
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 42dee4c3e9..092a9acd7c 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -316,17 +316,20 @@ public:
Optional<LLNotificationContext*> context;
Optional<void*> responder;
Optional<bool> offer_from_agent;
+ Optional<bool> is_dnd;
struct Functor : public LLInitParam::ChoiceBlock<Functor>
{
Alternative<std::string> name;
Alternative<LLNotificationFunctorRegistry::ResponseFunctor> function;
Alternative<LLNotificationResponderPtr> responder;
+ Alternative<LLSD> responder_sd;
Functor()
: name("responseFunctor"),
function("functor"),
- responder("responder")
+ responder("responder"),
+ responder_sd("responder_sd")
{}
};
Optional<Functor> functor;
@@ -340,7 +343,8 @@ public:
form_elements("form"),
substitutions("substitutions"),
expiry("expiry"),
- offer_from_agent("offer_from_agent", false)
+ offer_from_agent("offer_from_agent", false),
+ is_dnd("is_dnd", false)
{
time_stamp = LLDate::now();
responder = NULL;
@@ -354,7 +358,8 @@ public:
form_elements("form"),
substitutions("substitutions"),
expiry("expiry"),
- offer_from_agent("offer_from_agent", false)
+ offer_from_agent("offer_from_agent", false),
+ is_dnd("is_dnd", false)
{
functor.name = _name;
name = _name;
@@ -381,6 +386,7 @@ private:
void* mResponderObj; // TODO - refactor/remove this field
LLNotificationResponderPtr mResponder;
bool mOfferFromAgent;
+ bool mIsDND;
// a reference to the template
LLNotificationTemplatePtr mTemplatep;
@@ -521,6 +527,16 @@ public:
return mOfferFromAgent;
}
+ bool isDND() const
+ {
+ return mIsDND;
+ }
+
+ void setDND(const bool flag)
+ {
+ mIsDND = flag;
+ }
+
std::string getType() const;
std::string getMessage() const;
std::string getFooter() const;
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp
index f4560d5668..9bb2f27a46 100644
--- a/indra/newview/lldonotdisturbnotificationstorage.cpp
+++ b/indra/newview/lldonotdisturbnotificationstorage.cpp
@@ -109,16 +109,20 @@ void LLDoNotDisturbNotificationStorage::loadNotifications()
++notification_it)
{
LLSD notification_params = *notification_it;
- LLNotificationPtr notification(new LLNotification(notification_params));
+ const LLUUID& notificationID = notification_params["id"];
+ LLNotificationPtr notification = instance.find(notificationID);
- const LLUUID& notificationID = notification->id();
- if (instance.find(notificationID))
+ //Notification already exists in notification pipeline (same instance of app running)
+ if (notification)
{
+ notification->setDND(true);
instance.update(notification);
}
+ //Notification doesn't exist (different instance since restarted app while in DND mode)
else
{
- LLNotificationResponderInterface* responder = createResponder(notification_params["name"], notification_params["responder"]);
+ notification = (LLNotificationPtr) new LLNotification(notification_params.with("is_dnd", true));
+ LLNotificationResponderInterface* responder = createResponder(notification_params["responder_sd"]["responder_type"], notification_params["responder_sd"]);
if (responder == NULL)
{
LL_WARNS("LLDoNotDisturbNotificationStorage") << "cannot create responder for notification of type '"
diff --git a/indra/newview/llimhandler.cpp b/indra/newview/llimhandler.cpp
index 72967eb6c7..c2b29f36e8 100644
--- a/indra/newview/llimhandler.cpp
+++ b/indra/newview/llimhandler.cpp
@@ -36,6 +36,8 @@
using namespace LLNotificationsUI;
+extern void process_dnd_im(const LLSD& notification);
+
//--------------------------------------------------------------------------
LLIMHandler::LLIMHandler()
: LLCommunicationNotificationHandler("IM Notifications", "notifytoast")
@@ -60,44 +62,52 @@ void LLIMHandler::initChannel()
//--------------------------------------------------------------------------
bool LLIMHandler::processNotification(const LLNotificationPtr& notification)
{
- if(mChannel.isDead())
- {
- return false;
- }
-
- // arrange a channel on a screen
- if(!mChannel.get()->getVisible())
- {
- initChannel();
- }
-
- LLSD substitutions = notification->getSubstitutions();
-
- // According to comments in LLIMMgr::addMessage(), if we get message
- // from ourselves, the sender id is set to null. This fixes EXT-875.
- LLUUID avatar_id = substitutions["FROM_ID"].asUUID();
- if (avatar_id.isNull())
- avatar_id = gAgentID;
-
- LLToastIMPanel::Params im_p;
- im_p.notification = notification;
- im_p.avatar_id = avatar_id;
- im_p.from = substitutions["FROM"].asString();
- im_p.time = substitutions["TIME"].asString();
- im_p.message = substitutions["MESSAGE"].asString();
- im_p.session_id = substitutions["SESSION_ID"].asUUID();
-
- LLToastIMPanel* im_box = new LLToastIMPanel(im_p);
-
- LLToast::Params p;
- p.notif_id = notification->getID();
- p.session_id = im_p.session_id;
- p.notification = notification;
- p.panel = im_box;
- p.can_be_stored = false;
- LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel.get());
- if(channel)
- channel->addToast(p);
+ if(notification->isDND())
+ {
+ LLSD data = notification->asLLSD(); //don't need this if retrieve needed data from notification getters
+ process_dnd_im(data);
+ }
+ else
+ {
+ if(mChannel.isDead())
+ {
+ return false;
+ }
+
+ // arrange a channel on a screen
+ if(!mChannel.get()->getVisible())
+ {
+ initChannel();
+ }
+
+ LLSD substitutions = notification->getSubstitutions();
+
+ // According to comments in LLIMMgr::addMessage(), if we get message
+ // from ourselves, the sender id is set to null. This fixes EXT-875.
+ LLUUID avatar_id = substitutions["FROM_ID"].asUUID();
+ if (avatar_id.isNull())
+ avatar_id = gAgentID;
+
+ LLToastIMPanel::Params im_p;
+ im_p.notification = notification;
+ im_p.avatar_id = avatar_id;
+ im_p.from = substitutions["FROM"].asString();
+ im_p.time = substitutions["TIME"].asString();
+ im_p.message = substitutions["MESSAGE"].asString();
+ im_p.session_id = substitutions["SESSION_ID"].asUUID();
+
+ LLToastIMPanel* im_box = new LLToastIMPanel(im_p);
+
+ LLToast::Params p;
+ p.notif_id = notification->getID();
+ p.session_id = im_p.session_id;
+ p.notification = notification;
+ p.panel = im_box;
+ p.can_be_stored = false;
+ LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel.get());
+ if(channel)
+ channel->addToast(p);
+ }
return false;
}
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 2bb79a39e8..0011f54175 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -101,6 +101,43 @@ BOOL LLSessionTimeoutTimer::tick()
return TRUE;
}
+
+
+void process_dnd_im(const LLSD& notification)
+{
+ LLSD data = notification["substitutions"];
+ LLUUID sessionID = data["SESSION_ID"].asUUID();
+
+ //re-create the IM session if needed
+ //(when coming out of DND mode upon app restart)
+ if(!gIMMgr->hasSession(sessionID))
+ {
+ //reconstruct session using data from the notification
+ std::string name = data["FROM"];
+ LLAvatarName av_name;
+ if (LLAvatarNameCache::get(data["FROM_ID"], &av_name))
+ {
+ name = av_name.getDisplayName();
+ }
+
+
+ LLIMModel::getInstance()->newSession(sessionID,
+ name,
+ IM_NOTHING_SPECIAL,
+ data["FROM_ID"],
+ false,
+ false); //will need slight refactor to retrieve whether offline message or not (assume online for now)
+ }
+
+ //For now always flash conversation line item
+ LLFloaterIMContainer* im_box = LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container");
+ im_box->flashConversationItemWidget(sessionID, true);
+
+ //And flash toolbar button
+ gToolBarView->flashCommand(LLCommandId("chat"), true);
+}
+
+
static void on_avatar_name_cache_toast(const LLUUID& agent_id,
const LLAvatarName& av_name,
LLSD msg)
diff --git a/indra/newview/llnotificationstorage.cpp b/indra/newview/llnotificationstorage.cpp
index b797775369..4c5b7cc198 100644
--- a/indra/newview/llnotificationstorage.cpp
+++ b/indra/newview/llnotificationstorage.cpp
@@ -126,13 +126,8 @@ LLResponderRegistry::LLResponderRegistry()
, mBuildMap()
{
add("ObjectGiveItem", &create<LLOfferInfo>);
- add("OwnObjectGiveItem", &create<LLOfferInfo>);
add("UserGiveItem", &create<LLOfferInfo>);
-
- add("TeleportOffered", &create<LLOfferInfo>);
- add("TeleportOffered_MaturityExceeded", &create<LLOfferInfo>);
-
- add("OfferFriendship", &create<LLOfferInfo>);
+ add("offer_info", &create<LLOfferInfo>);
}
LLResponderRegistry::~LLResponderRegistry()
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 61716d1d5b..db81e057de 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -1361,6 +1361,8 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id,
gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(blocked_id));
}
+std::string LLOfferInfo::mResponderType = "offer_info";
+
LLOfferInfo::LLOfferInfo()
: LLNotificationResponderInterface()
, mFromGroup(FALSE)
@@ -1406,6 +1408,7 @@ LLOfferInfo::LLOfferInfo(const LLOfferInfo& info)
LLSD LLOfferInfo::asLLSD()
{
LLSD sd;
+ sd["responder_type"] = mResponderType;
sd["im_type"] = mIM;
sd["from_id"] = mFromID;
sd["from_group"] = mFromGroup;
diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h
index 447fdeb9c7..3237f3fbdd 100644
--- a/indra/newview/llviewermessage.h
+++ b/indra/newview/llviewermessage.h
@@ -229,6 +229,7 @@ public:
void forceResponse(InventoryOfferResponse response);
+ static std::string mResponderType;
EInstantMessage mIM;
LLUUID mFromID;
BOOL mFromGroup;