diff options
| author | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-01-08 17:06:49 -0800 | 
|---|---|---|
| committer | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-01-08 17:06:49 -0800 | 
| commit | b5172de28fd6bb8a833cf93180d2d43dd9d4a073 (patch) | |
| tree | cc7fcf7335feb85245daa64575eb1a01366e7233 | |
| parent | 974720373d608a8cbcd3cd26c125b6487b5926a2 (diff) | |
CHUI-660: Post code review changes
| -rw-r--r-- | indra/llui/llnotifications.cpp | 51 | ||||
| -rw-r--r-- | indra/llui/llnotifications.h | 4 | ||||
| -rw-r--r-- | indra/newview/lldonotdisturbnotificationstorage.cpp | 2 | 
3 files changed, 34 insertions, 23 deletions
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index ebdb4d5024..a5492b46f7 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -279,6 +279,18 @@ bool LLNotificationForm::hasElement(const std::string& element_name) const  	return false;  } +void LLNotificationForm::getElements(LLSD& elements, S32 offset) +{ +    //Finds elements that the template did not add +    LLSD::array_const_iterator it = mFormData.beginArray() + offset; + +    //Keeps track of only the dynamic elements +    for(; it != mFormData.endArray(); ++it) +    { +        elements.append(*it); +    } +} +  bool LLNotificationForm::getElementEnabled(const std::string& element_name) const  {  	for (LLSD::array_const_iterator it = mFormData.beginArray(); @@ -320,11 +332,6 @@ void LLNotificationForm::addElement(const std::string& type, const std::string&  	mFormData.append(element);  } -void LLNotificationForm::addElement(const LLSD& element) -{ -    mFormData.append(element); -} -  void LLNotificationForm::append(const LLSD& sub_form)  {  	if (sub_form.isArray()) @@ -508,21 +515,36 @@ LLNotification::LLNotification(const LLSDParamAdapter<Params>& p) :  } -LLSD LLNotification::asLLSD() +LLSD LLNotification::asLLSD(bool excludeTemplateElements)  {  	LLParamSDParser parser;  	Params p;  	p.id = mId;  	p.name = mTemplatep->mName; -	p.form_elements = getForm()->asLLSD(); -	  	p.substitutions = mSubstitutions;  	p.payload = mPayload;  	p.time_stamp = mTimestamp;  	p.expiry = mExpiresAt;  	p.priority = mPriority; +    LLNotificationFormPtr templateForm = mTemplatep->mForm; +    LLSD formElements = mForm->asLLSD(); + +    //All form elements (dynamic or not) +    if(!excludeTemplateElements) +    { +        p.form_elements = formElements; +    } +    //Only dynamic form elements (exclude template elements) +    else if(templateForm->getNumElements() < formElements.size()) +    { +        LLSD dynamicElements; +        //Offset to dynamic elements and store them +        mForm->getElements(dynamicElements, templateForm->getNumElements()); +        p.form_elements = dynamicElements; +    } +          if(mResponder)      {          p.functor.responder_sd = mResponder->asLLSD(); @@ -823,18 +845,7 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele  	//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);  	mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm)); - -    //Prevents appending elements(buttons) that the template already had -    if(form_elements.isArray() -        && mForm->getNumElements() < form_elements.size()) -    { -        LLSD::array_const_iterator it = form_elements.beginArray() + mForm->getNumElements();; - -        for(; it != form_elements.endArray(); ++it) -        { -            mForm->addElement(*it); -        } -    } +    mForm->append(form_elements);  	// apply substitution to form labels  	mForm->formatElements(mSubstitutions); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 96e0a86b7f..236c2a42d1 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -242,11 +242,11 @@ public:  	S32 getNumElements() { return mFormData.size(); }  	LLSD getElement(S32 index) { return mFormData.get(index); }  	LLSD getElement(const std::string& element_name); +    void getElements(LLSD& elements, S32 offset = 0);  	bool hasElement(const std::string& element_name) const;  	bool getElementEnabled(const std::string& element_name) const;  	void setElementEnabled(const std::string& element_name, bool enabled);  	void addElement(const std::string& type, const std::string& name, const LLSD& value = LLSD(), bool enabled = true); -    void addElement(const LLSD &element);  	void formatElements(const LLSD& substitutions);  	// appends form elements from another form serialized as LLSD  	void append(const LLSD& sub_form); @@ -457,7 +457,7 @@ public:  	// ["time"] = time at which notification was generated;  	// ["expiry"] = time at which notification expires;  	// ["responseFunctor"] = name of registered functor that handles responses to notification; -	LLSD asLLSD(); +	LLSD asLLSD(bool excludeTemplateElements = false);  	const LLNotificationFormPtr getForm();  	void updateForm(const LLNotificationFormPtr& form); diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp index 9bb2f27a46..ac41a3804f 100644 --- a/indra/newview/lldonotdisturbnotificationstorage.cpp +++ b/indra/newview/lldonotdisturbnotificationstorage.cpp @@ -77,7 +77,7 @@ void LLDoNotDisturbNotificationStorage::saveNotifications()  		if (!notificationPtr->isRespondedTo() && !notificationPtr->isCancelled() && !notificationPtr->isExpired())  		{ -			data.append(notificationPtr->asLLSD()); +			data.append(notificationPtr->asLLSD(true));  		}  	}  | 
