summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-04-22 11:03:18 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-04-22 11:03:18 +0100
commitce8451a2578e09c00ef53b768a5dbb3e87999d0c (patch)
tree1213eb2c146e368f89b8b481df926a51641823d0 /indra/newview/llviewermessage.cpp
parent7bb4436b488f70d842cd1382d8089ecae29234c0 (diff)
parenta4e20e993250022872e5f4add8fb49004f9f7dbf (diff)
merge from PE's viewer-trunk 'notifications'
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r--indra/newview/llviewermessage.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 43c3042c65..486158272d 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -1247,6 +1247,16 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id,
gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(blocked_id));
}
+LLOfferInfo::LLOfferInfo()
+ : LLNotificationResponderInterface()
+ , mFromGroup(FALSE)
+ , mFromObject(FALSE)
+ , mIM(IM_NOTHING_SPECIAL)
+ , mType(LLAssetType::AT_NONE)
+ , mPersist(false)
+{
+}
+
LLOfferInfo::LLOfferInfo(const LLSD& sd)
{
mIM = (EInstantMessage)sd["im_type"].asInteger();
@@ -1260,6 +1270,7 @@ LLOfferInfo::LLOfferInfo(const LLSD& sd)
mFromName = sd["from_name"].asString();
mDesc = sd["description"].asString();
mHost = LLHost(sd["sender"].asString());
+ mPersist = sd["persist"].asBoolean();
}
LLOfferInfo::LLOfferInfo(const LLOfferInfo& info)
@@ -1275,6 +1286,7 @@ LLOfferInfo::LLOfferInfo(const LLOfferInfo& info)
mFromName = info.mFromName;
mDesc = info.mDesc;
mHost = info.mHost;
+ mPersist = info.mPersist;
}
LLSD LLOfferInfo::asLLSD()
@@ -1291,9 +1303,15 @@ LLSD LLOfferInfo::asLLSD()
sd["from_name"] = mFromName;
sd["description"] = mDesc;
sd["sender"] = mHost.getIPandPort();
+ sd["persist"] = mPersist;
return sd;
}
+void LLOfferInfo::fromLLSD(const LLSD& params)
+{
+ *this = params;
+}
+
void LLOfferInfo::send_auto_receive_response(void)
{
LLMessageSystem* msg = gMessageSystem;
@@ -1333,6 +1351,21 @@ void LLOfferInfo::send_auto_receive_response(void)
}
}
+void LLOfferInfo::handleRespond(const LLSD& notification, const LLSD& response)
+{
+ initRespondFunctionMap();
+
+ const std::string name = notification["name"].asString();
+ if(mRespondFunctions.find(name) == mRespondFunctions.end())
+ {
+ llwarns << "Unexpected notification name : " << name << llendl;
+ llassert(!"Unexpected notification name");
+ return;
+ }
+
+ mRespondFunctions[name](notification, response);
+}
+
bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& response)
{
LLChat chat;
@@ -1469,7 +1502,10 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
gInventory.addObserver(opener);
}
- delete this;
+ if(!mPersist)
+ {
+ delete this;
+ }
return false;
}
@@ -1635,7 +1671,10 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const
gInventory.addObserver(opener);
}
- delete this;
+ if(!mPersist)
+ {
+ delete this;
+ }
return false;
}
@@ -1651,6 +1690,15 @@ protected:
}
};
+void LLOfferInfo::initRespondFunctionMap()
+{
+ if(mRespondFunctions.empty())
+ {
+ mRespondFunctions["ObjectGiveItem"] = boost::bind(&LLOfferInfo::inventory_task_offer_callback, this, _1, _2);
+ mRespondFunctions["UserGiveItem"] = boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2);
+ }
+}
+
void inventory_offer_handler(LLOfferInfo* info)
{
//Until throttling is implmented, busy mode should reject inventory instead of silently
@@ -1767,7 +1815,8 @@ void inventory_offer_handler(LLOfferInfo* info)
// Inventory Slurls don't currently work for non agent transfers, so only display the object name.
args["ITEM_SLURL"] = msg;
// Note: sets inventory_task_offer_callback as the callback
- p.substitutions(args).payload(payload).functor.function(boost::bind(&LLOfferInfo::inventory_task_offer_callback, info, _1, _2));
+ p.substitutions(args).payload(payload).functor.responder(LLNotificationResponderPtr(info));
+ info->mPersist = true;
p.name = name_found ? "ObjectGiveItem" : "ObjectGiveItemUnknownUser";
// Pop up inv offer chiclet and let the user accept (keep), or reject (and silently delete) the inventory.
LLNotifications::instance().add(p);
@@ -1779,7 +1828,8 @@ void inventory_offer_handler(LLOfferInfo* info)
// *TODO fix memory leak
// inventory_offer_callback() is not invoked if user received notification and
// closes viewer(without responding the notification)
- p.substitutions(args).payload(payload).functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2));
+ p.substitutions(args).payload(payload).functor.responder(LLNotificationResponderPtr(info));
+ info->mPersist = true;
p.name = "UserGiveItem";
// Prefetch the item into your local inventory.