From 94bf2e4e9b30d8d20895d314442e6bf8b2dec383 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 23 Sep 2010 16:06:57 +0200 Subject: [PATCH] - added : inv_offer notifications for "Give to #RLV" inventory offers -> see RLV-2.2.0 --HG-- branch : RLVa --- indra/newview/llviewermessage.cpp | 41 +++++++++++++++++++++++++------ indra/newview/rlvhelper.cpp | 28 ++++++++++++++------- indra/newview/rlvhelper.h | 2 +- indra/newview/rlvinventory.cpp | 2 ++ 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a44cbeb519..86275db2a9 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1677,6 +1677,9 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const bool busy=FALSE; +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + bool fRlvNotifyAccepted = false; +// [/RLVa:KB] switch(button) { case IOR_ACCEPT: @@ -1684,21 +1687,26 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // for inventory_offered, task_inventory_offer or // group_notice_inventory is 1 greater than the offer integer value. -// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Modified: RLVa-1.2.1e // Only change the inventory offer's destination folder to the shared root if: // - the user has enabled the feature // - the inventory offer came from a script (and specifies a folder) // - the name starts with the prefix - mDesc format: '[OBJECTNAME]' ( http://slurl.com/... ) - if ( (rlv_handler_t::isEnabled()) && (!RlvSettings::getForbidGiveToRLV()) && + if ( (rlv_handler_t::isEnabled()) && (IM_TASK_INVENTORY_OFFERED == mIM) && (LLAssetType::AT_CATEGORY == mType) && (mDesc.find(RLV_PUTINV_PREFIX) == 1) ) { - const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); - if (pRlvRoot) + fRlvNotifyAccepted = true; + if (!RlvSettings::getForbidGiveToRLV()) { - mFolderID = pRlvRoot->getUUID(); + const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot(); + if (pRlvRoot) + { + fRlvNotifyAccepted = false; // "accepted_in_rlv" is sent from RlvGiveToRLVTaskOffer *after* we have the folder + mFolderID = pRlvRoot->getUUID(); - RlvGiveToRLVTaskOffer* pOfferObserver = new RlvGiveToRLVTaskOffer(mTransactionID); - gInventory.addObserver(pOfferObserver); + RlvGiveToRLVTaskOffer* pOfferObserver = new RlvGiveToRLVTaskOffer(mTransactionID); + gInventory.addObserver(pOfferObserver); + } } } // [/RLVa:KB] @@ -1711,6 +1719,15 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // send the message msg->sendReliable(mHost); +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + if (fRlvNotifyAccepted) + { + std::string::size_type idxToken = mDesc.find("' ( http://"); + if (std::string::npos != idxToken) + RlvBehaviourNotifyHandler::instance().sendNotification("accepted_in_inv inv_offer " + mDesc.substr(1, idxToken - 1)); + } +// [/RLVa:KB] + //don't spam them if they are getting flooded if (check_offer_throttle(mFromName, true)) { @@ -1759,6 +1776,16 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // send the message msg->sendReliable(mHost); +// [RLVa:KB] - Checked: 2010-09-23 (RLVa-1.2.1e) | Added: RLVa-1.2.1e + if ( (rlv_handler_t::isEnabled()) && + (IM_TASK_INVENTORY_OFFERED == mIM) && (LLAssetType::AT_CATEGORY == mType) && (mDesc.find(RLV_PUTINV_PREFIX) == 1) ) + { + std::string::size_type idxToken = mDesc.find("' ( http://"); + if (std::string::npos != idxToken) + RlvBehaviourNotifyHandler::instance().sendNotification("declined inv_offer " + mDesc.substr(1, idxToken - 1)); + } +// [/RLVa:KB] + log_message = LLTrans::getString("InvOfferYouDecline") + " " + mDesc + " " + LLTrans::getString("InvOfferFrom") + " " + mFromName +"."; LLSD args; args["MESSAGE"] = log_message; diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 92b565d355..6c6ec8d4bd 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -891,19 +891,29 @@ void RlvBehaviourNotifyHandler::onCommand(const RlvCommand& rlvCmd, ERlvCmdRet e if (fInternal) return; - std::string strCmd = rlvCmd.asString(), strNotify; ERlvParamType eCmdType = rlvCmd.getParamType(); - if ( (RLV_TYPE_ADD == eCmdType) || (RLV_TYPE_REMOVE == eCmdType) ) - strNotify = llformat("/%s=%s", strCmd.c_str(), rlvCmd.getParam().c_str()); - else if (RLV_TYPE_CLEAR == eCmdType) - strNotify = llformat("/%s", strCmd.c_str()); - else - return; + switch (rlvCmd.getParamType()) + { + case RLV_TYPE_ADD: + case RLV_TYPE_REMOVE: + sendNotification(rlvCmd.asString(), "=" + rlvCmd.getParam()); + break; + case RLV_TYPE_CLEAR: + sendNotification(rlvCmd.asString()); + break; + default: + break; + } +} +// Checked: 2010-09-23 (RLVa-1.2.1e) | Modified: RLVa-1.2.1e +void RlvBehaviourNotifyHandler::sendNotification(const std::string& strText, const std::string& strSuffix) const +{ + // NOTE: notifications have two parts (which are concatenated without token) where only the first part is subject to the filter for (std::multimap::const_iterator itNotify = m_Notifications.begin(); itNotify != m_Notifications.end(); ++itNotify) { - if ( (itNotify->second.strFilter.empty()) || (std::string::npos != strCmd.find(itNotify->second.strFilter)) ) - RlvUtil::sendChatReply(itNotify->second.nChannel, strNotify); + if ( (itNotify->second.strFilter.empty()) || (std::string::npos != strText.find(itNotify->second.strFilter)) ) + RlvUtil::sendChatReply(itNotify->second.nChannel, "/" + strText + strSuffix); } } diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 85962f6287..64c1fae1c5 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -303,7 +303,6 @@ private: // RlvBehaviourNotifyObserver // -// TODO-RLVa: [RLVa-1.2.1] See about just reintegrating this back into RlvHandler class RlvBehaviourNotifyHandler : public LLSingleton { friend class LLSingleton; @@ -330,6 +329,7 @@ public: if (m_Notifications.empty()) delete this; // Delete ourself if we have nothing to do } + void sendNotification(const std::string& strText, const std::string& strSuffix = LLStringUtil::null) const; protected: void onCommand(const RlvCommand& rlvCmd, ERlvCmdRet eRet, bool fInternal); diff --git a/indra/newview/rlvinventory.cpp b/indra/newview/rlvinventory.cpp index 4f4c1667a0..d3de6f7fc3 100644 --- a/indra/newview/rlvinventory.cpp +++ b/indra/newview/rlvinventory.cpp @@ -495,6 +495,8 @@ void RlvGiveToRLVTaskOffer::doneIdle() pNewFolder->updateServer(FALSE); gInventory.updateCategory(pNewFolder); + RlvBehaviourNotifyHandler::instance().sendNotification("accepted_in_rlv inv_offer " + pNewFolder->getName()); + gInventory.notifyObservers(); break; }