diff options
| author | Cho <cho@lindenlab.com> | 2013-01-18 02:05:59 +0000 | 
|---|---|---|
| committer | Cho <cho@lindenlab.com> | 2013-01-18 02:05:59 +0000 | 
| commit | 414b699f8f926c8400e64b9ba052f34b297a391c (patch) | |
| tree | 99a236acf8a6ee859c46e6bd416f84891b174110 /indra | |
| parent | 1780e78884c1b111f4a48bea578e28b370fbe45c (diff) | |
| parent | d0235ad1789d05524065307f4514a76d55f4e847 (diff) | |
merging latest changes
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.cpp | 62 | ||||
| -rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.h | 3 | ||||
| -rw-r--r-- | indra/newview/llfloaterimcontainer.cpp | 16 | ||||
| -rw-r--r-- | indra/newview/llnotificationstorage.cpp | 93 | ||||
| -rwxr-xr-x | indra/newview/llviewermessage.cpp | 11 | 
5 files changed, 78 insertions, 107 deletions
| diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp index 42b455c1ce..824ff67972 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.cpp +++ b/indra/newview/lldonotdisturbnotificationstorage.cpp @@ -43,15 +43,16 @@  #include "lluuid.h"  static const F32 DND_TIMER = 3.0; +const std::string toastName = "IMToast";  LLDoNotDisturbNotificationStorageTimer::LLDoNotDisturbNotificationStorageTimer() : LLEventTimer(DND_TIMER)  { -    mEventTimer.start(); +  }  LLDoNotDisturbNotificationStorageTimer::~LLDoNotDisturbNotificationStorageTimer()  { -    mEventTimer.stop(); +  }  BOOL LLDoNotDisturbNotificationStorageTimer::tick() @@ -152,27 +153,27 @@ void LLDoNotDisturbNotificationStorage::loadNotifications()          std::string notificationName = notification_params["name"];          LLNotificationPtr notification = instance.find(notificationID); -        if(notificationName == "IMToast") +        if(notificationName == toastName)          {              imToastExists = true;          }          //New notification needs to be added -            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 '" -					<< notification->getType() << "'" << LL_ENDL; -			} -			else -			{ -				LLNotificationResponderPtr responderPtr(responder); -				notification->setResponseFunctor(responderPtr); -			} -			 -			instance.add(notification); +        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 '" +				<< notification->getType() << "'" << LL_ENDL;  		} +		else +		{ +			LLNotificationResponderPtr responderPtr(responder); +			notification->setResponseFunctor(responderPtr); +		} +			 +		instance.add(notification); +	}      if(imToastExists)      { @@ -200,7 +201,7 @@ void LLDoNotDisturbNotificationStorage::updateNotifications()          LLNotificationPtr notification = it->second;          std::string notificationName = notification->getName(); -        if(notificationName == "IMToast") +        if(notificationName == toastName)          {              imToastExists = true;          } @@ -221,9 +222,9 @@ void LLDoNotDisturbNotificationStorage::updateNotifications()      //When exit DND mode, write empty notifications file      if(commChannel->getHistorySize())      { -	commChannel->clearHistory(); -	saveNotifications(); -} +	    commChannel->clearHistory(); +	    saveNotifications(); +    }  }  LLNotificationChannelPtr LLDoNotDisturbNotificationStorage::getCommunicationChannel() const @@ -241,6 +242,7 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi      LLNotificationPtr notification;      LLSD substitutions;      LLUUID notificationSessionID; +    std::string notificationName;      LLCommunicationChannel::history_list_t::iterator it;      std::vector<LLCommunicationChannel::history_list_t::iterator> itemsToRemove; @@ -252,8 +254,10 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi          notification = it->second;          substitutions = notification->getSubstitutions();          notificationSessionID = substitutions["SESSION_ID"].asUUID(); +        notificationName = notification->getName(); -        if(session_id == notificationSessionID) +        if(notificationName == toastName +            && session_id == notificationSessionID)          {              itemsToRemove.push_back(it);          } @@ -263,14 +267,14 @@ void LLDoNotDisturbNotificationStorage::removeIMNotification(const LLUUID& sessi      //Remove the notifications      if(itemsToRemove.size())      { -    while(itemsToRemove.size()) -    { -        it = itemsToRemove.back(); -        notification = it->second; +        while(itemsToRemove.size()) +        { +            it = itemsToRemove.back(); +            notification = it->second;              commChannel->removeItemFromHistory(notification); -        instance.cancel(notification); -        itemsToRemove.pop_back(); -    } +            instance.cancel(notification); +            itemsToRemove.pop_back(); +        }          //Trigger saving of notifications to xml once all have been removed          saveNotifications();      } diff --git a/indra/newview/lldonotdisturbnotificationstorage.h b/indra/newview/lldonotdisturbnotificationstorage.h index fd03b71357..fd7cc7ee82 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.h +++ b/indra/newview/lldonotdisturbnotificationstorage.h @@ -42,9 +42,6 @@ public:      ~LLDoNotDisturbNotificationStorageTimer();  public: -    void startTimer(); -    void stopTimer(); -    bool isRunning();      BOOL tick();  }; diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index cc23449449..8f290ae7c1 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -1299,11 +1299,14 @@ BOOL LLFloaterIMContainer::selectConversationPair(const LLUUID& session_id, bool      	if (widget && widget->getParentFolder())      	{      		widget->getParentFolder()->setSelection(widget, FALSE, FALSE); -            if(gAgent.isDoNotDisturb()) -            { -                LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id); -            }      	} + +        //When in DND mode, remove stored IM notifications +        //Nearby chat (Null) IMs are not stored while in DND mode, so can ignore removal +        if(gAgent.isDoNotDisturb() && session_id.notNull()) +        { +            LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id); +        }      }      /* floater processing */ @@ -1324,11 +1327,6 @@ BOOL LLFloaterIMContainer::selectConversationPair(const LLUUID& session_id, bool  				// Switch to the conversation floater that is being selected  				selectFloater(session_floater);  			} - -            if(gAgent.isDoNotDisturb()) -            { -                LLDoNotDisturbNotificationStorage::getInstance()->removeIMNotification(session_id); -            }  		}  		// Set the focus on the selected floater diff --git a/indra/newview/llnotificationstorage.cpp b/indra/newview/llnotificationstorage.cpp index 4c5b7cc198..b6184f09bf 100644 --- a/indra/newview/llnotificationstorage.cpp +++ b/indra/newview/llnotificationstorage.cpp @@ -38,30 +38,43 @@  #include "llsd.h"  #include "llsdserialize.h"  #include "llsingleton.h" -#include "llviewermessage.h" +#include "llregistry.h" +#include "llviewermessage.h"  +typedef boost::function<LLNotificationResponderInterface * (const LLSD& pParams)> responder_constructor_t; -class LLResponderRegistry : public LLSingleton<LLResponderRegistry> +class LLResponderRegistry : public LLRegistrySingleton<std::string, responder_constructor_t, LLResponderRegistry>  { -public: -	LLResponderRegistry(); -	~LLResponderRegistry(); -	 -	LLNotificationResponderInterface* createResponder(const std::string& pNotificationName, const LLSD& pParams); -	 -protected: -	 -private: -	template<typename RESPONDER_TYPE> static LLNotificationResponderInterface* create(const LLSD& pParams); -	 -	typedef boost::function<LLNotificationResponderInterface* (const LLSD& params)> responder_constructor_t; -	 -	void add(const std::string& pNotificationName, const responder_constructor_t& pConstructor); -	 -	typedef std::map<std::string, responder_constructor_t> build_map_t; -	build_map_t mBuildMap; +    public: +        template<typename RESPONDER_TYPE> static LLNotificationResponderInterface * create(const LLSD& pParams); +        LLNotificationResponderInterface * createResponder(const std::string& pNotificationName, const LLSD& pParams);  }; +template<typename RESPONDER_TYPE> LLNotificationResponderInterface * LLResponderRegistry::create(const LLSD& pParams) +{ +    RESPONDER_TYPE* responder = new RESPONDER_TYPE(); +    responder->fromLLSD(pParams); +    return responder; +} + + +LLNotificationResponderInterface * LLResponderRegistry::createResponder(const std::string& pNotificationName, const LLSD& pParams) +{ +    responder_constructor_t * factoryFunc = (LLResponderRegistry::getValue(pNotificationName)); + +    if(factoryFunc) +    { +        return (*factoryFunc)(pParams); +    } +     +    return NULL; +} + +LLResponderRegistry::StaticRegistrar sRegisterObjectGiveItem("ObjectGiveItem", &LLResponderRegistry::create<LLOfferInfo>); +LLResponderRegistry::StaticRegistrar sRegisterUserGiveItem("UserGiveItem", &LLResponderRegistry::create<LLOfferInfo>); +LLResponderRegistry::StaticRegistrar sRegisterOfferInfo("offer_info", &LLResponderRegistry::create<LLOfferInfo>); + +  LLNotificationStorage::LLNotificationStorage(std::string pFileName)  	: mFileName(pFileName)  { @@ -116,47 +129,7 @@ bool LLNotificationStorage::readNotifications(LLSD& pNotificationData) const  	return didFileRead;  } -LLNotificationResponderInterface* LLNotificationStorage::createResponder(const std::string& pNotificationName, const LLSD& pParams) const +LLNotificationResponderInterface * LLNotificationStorage::createResponder(const std::string& pNotificationName, const LLSD& pParams) const  {  	return LLResponderRegistry::getInstance()->createResponder(pNotificationName, pParams);  } - -LLResponderRegistry::LLResponderRegistry() -	: LLSingleton<LLResponderRegistry>() -	, mBuildMap() -{ -	add("ObjectGiveItem", &create<LLOfferInfo>); -	add("UserGiveItem", &create<LLOfferInfo>); -    add("offer_info", &create<LLOfferInfo>); -} - -LLResponderRegistry::~LLResponderRegistry() -{ -} - -LLNotificationResponderInterface* LLResponderRegistry::createResponder(const std::string& pNotificationName, const LLSD& pParams) -{ -	build_map_t::const_iterator it = mBuildMap.find(pNotificationName); -	if(mBuildMap.end() == it) -	{ -		return NULL; -	} -	responder_constructor_t ctr = it->second; -	return ctr(pParams); -} - -template<typename RESPONDER_TYPE> LLNotificationResponderInterface* LLResponderRegistry::create(const LLSD& pParams) -{ -	RESPONDER_TYPE* responder = new RESPONDER_TYPE(); -	responder->fromLLSD(pParams); -	return responder; -} -	 -void LLResponderRegistry::add(const std::string& pNotificationName, const responder_constructor_t& pConstructor) -{ -	if (mBuildMap.find(pNotificationName) != mBuildMap.end()) -	{ -		LL_ERRS("LLResponderRegistry") << "Responder is already registered : " << pNotificationName << LL_ENDL; -	} -	mBuildMap.insert(std::make_pair<std::string, responder_constructor_t>(pNotificationName, pConstructor)); -} diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 4bff0222bd..d235ba5f96 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1622,12 +1622,6 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&  			{  				opener = discard_agent_offer;  			} -			 -			 -			if (gAgent.isDoNotDisturb() && (!mFromGroup && !mFromObject)) -			{ -				send_do_not_disturb_message(gMessageSystem, mFromID); -			}  			if (modified_form != NULL)  			{ @@ -1995,6 +1989,11 @@ void inventory_offer_handler(LLOfferInfo* info)  		// In viewer 2 we're now auto receiving inventory offers and messaging as such (not sending reject messages).  		info->send_auto_receive_response(); +        if (gAgent.isDoNotDisturb())  +        { +            send_do_not_disturb_message(gMessageSystem, info->mFromID); +        } +  		// Inform user that there is a script floater via toast system  		{  			payload["give_inventory_notification"] = TRUE; | 
