diff options
author | dolphin <dolphin@lindenlab.com> | 2013-10-22 10:51:53 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-10-22 10:51:53 -0700 |
commit | 309ffd57fade231c3d14eedfe1171788e250f088 (patch) | |
tree | 61b6bfb1072bdb67b0399b90288525f647648a03 /indra/newview | |
parent | 035eafb0c69c434c709862c816663f2b4ca2ab2b (diff) |
Post events on experience permission changes to refresh uis
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterexperienceprofile.cpp | 140 | ||||
-rw-r--r-- | indra/newview/llfloaterexperienceprofile.h | 9 | ||||
-rw-r--r-- | indra/newview/llfloaterexperiences.cpp | 83 | ||||
-rw-r--r-- | indra/newview/llfloaterexperiences.h | 12 | ||||
-rw-r--r-- | indra/newview/llpanelexperiences.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llpanelexperiences.h | 2 | ||||
-rwxr-xr-x | indra/newview/llviewermessage.cpp | 25 |
7 files changed, 239 insertions, 52 deletions
diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index 0e868e199d..25dde49b8e 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -47,6 +47,7 @@ #include "lltexturectrl.h" #include "lltrans.h" #include "llviewerregion.h" +#include "llevents.h" #define XML_PANEL_EXPERIENCE_PROFILE "floater_experienceprofile.xml" #define TF_NAME "experience_title" @@ -157,21 +158,16 @@ public: -class ExperiencePreferencesResponder : public HandleResponder<LLFloaterExperienceProfile> +class ExperiencePreferencesResponder : public LLHTTPClient::Responder { public: - ExperiencePreferencesResponder(const LLHandle<LLFloaterExperienceProfile>& parent):HandleResponder<LLFloaterExperienceProfile>(parent) + ExperiencePreferencesResponder() { } - virtual void result(const LLSD& content) { - LLFloaterExperienceProfile* parent=mParent.get(); - if(parent) - { - parent->setPreferences(content); - } + LLEventPumps::instance().obtain("experience_permission").post(content); } }; @@ -230,7 +226,7 @@ BOOL LLFloaterExperienceProfile::postBuild() lookup_url=region->getCapability("ExperiencePreferences"); if(!lookup_url.empty()) { - LLHTTPClient::get(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + LLHTTPClient::get(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder()); } } } @@ -254,6 +250,10 @@ BOOL LLFloaterExperienceProfile::postBuild() childSetCommitCallback(EDIT BTN_PRIVATE, boost::bind(&LLFloaterExperienceProfile::onFieldChanged, this), NULL); getChild<LLTextEditor>(EDIT TF_DESC)->setCommitOnFocusLost(TRUE); + + + LLEventPumps::instance().obtain("experience_permission").listen(mExperienceId.asString()+"-profile", + boost::bind(&LLFloaterExperienceProfile::experiencePermission, getDerivedHandle<LLFloaterExperienceProfile>(this), _1)); return TRUE; } @@ -267,6 +267,18 @@ void LLFloaterExperienceProfile::experienceCallback(LLHandle<LLFloaterExperience } } + +bool LLFloaterExperienceProfile::experiencePermission( LLHandle<LLFloaterExperienceProfile> handle, const LLSD& permission ) +{ + LLFloaterExperienceProfile* pllpep = handle.get(); + if(pllpep) + { + pllpep->updatePermission(permission); + } + return false; +} + + void LLFloaterExperienceProfile::onClickEdit() { LLTabContainer* tabs = getChild<LLTabContainer>("tab_container"); @@ -300,7 +312,7 @@ void LLFloaterExperienceProfile::onClickPermission(const char* perm) permission["permission"]=perm; data[mExperienceId.asString()]=permission; - LLHTTPClient::put(lookup_url, data, new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + LLHTTPClient::put(lookup_url, data, new ExperiencePreferencesResponder()); } @@ -315,7 +327,7 @@ void LLFloaterExperienceProfile::onClickForget() if(lookup_url.empty()) return; - LLHTTPClient::del(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + LLHTTPClient::del(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder()); } bool LLFloaterExperienceProfile::setMaturityString( U8 maturity, LLTextBox* child, LLComboBox* combo ) @@ -503,21 +515,13 @@ void LLFloaterExperienceProfile::setPreferences( const LLSD& content ) { const LLSD& experiences = content["experiences"]; const LLSD& blocked = content["blocked"]; - LLButton* button; for(LLSD::array_const_iterator it = experiences.beginArray(); it != experiences.endArray() ; ++it) { if(it->asUUID()==mExperienceId) { - button=getChild<LLButton>(BTN_ALLOW); - button->setEnabled(FALSE); - - button=getChild<LLButton>(BTN_FORGET); - button->setEnabled(TRUE); - - button=getChild<LLButton>(BTN_BLOCK); - button->setEnabled(TRUE); + experienceAllowed(); return; } } @@ -526,27 +530,12 @@ void LLFloaterExperienceProfile::setPreferences( const LLSD& content ) { if(it->asUUID()==mExperienceId) { - button=getChild<LLButton>(BTN_ALLOW); - button->setEnabled(TRUE); - - button=getChild<LLButton>(BTN_FORGET); - button->setEnabled(TRUE); - - button=getChild<LLButton>(BTN_BLOCK); - button->setEnabled(FALSE); + experienceBlocked(); return; } } - - button=getChild<LLButton>(BTN_ALLOW); - button->setEnabled(TRUE); - - button=getChild<LLButton>(BTN_FORGET); - button->setEnabled(FALSE); - - button=getChild<LLButton>(BTN_BLOCK); - button->setEnabled(TRUE); + experienceForgotten(); } void LLFloaterExperienceProfile::onFieldChanged() @@ -620,7 +609,15 @@ void LLFloaterExperienceProfile::doSave( int success_action ) package[LLExperienceCache::NAME] = getChild<LLLineEditor>(EDIT TF_NAME)->getText(); package[LLExperienceCache::DESCRIPTION] = getChild<LLTextEditor>(EDIT TF_DESC)->getText(); - package[LLExperienceCache::SLURL] = getChild<LLTextBox>(EDIT TF_SLURL)->getText(); + std::string slurl = getChild<LLTextBox>(EDIT TF_SLURL)->getText(); + if(slurl == getString("empty_slurl")) + { + package[LLExperienceCache::SLURL] = LLStringUtil::null; + } + else + { + package[LLExperienceCache::SLURL] = slurl; + } package[LLExperienceCache::MATURITY] = getChild<LLComboBox>(EDIT TF_MATURITY)->getSelectedValue().asInteger(); @@ -736,3 +733,70 @@ void LLFloaterExperienceProfile::onClickClear() child->setText(getString("empty_slurl")); onFieldChanged(); } + +void LLFloaterExperienceProfile::updatePermission( const LLSD& permission ) +{ + std::string xp = mExperienceId.asString(); + if(permission.has(xp)) + { + std::string str = permission[xp]["permission"].asString(); + if(str == "Allow") + { + experienceAllowed(); + } + else if(str == "Block") + { + experienceBlocked(); + } + else if(str == "Forget") + { + experienceForgotten(); + } + } + else + { + setPreferences(permission); + } +} + +void LLFloaterExperienceProfile::experienceAllowed() +{ + LLButton* button=getChild<LLButton>(BTN_ALLOW); + button->setEnabled(FALSE); + + button=getChild<LLButton>(BTN_FORGET); + button->setEnabled(TRUE); + + button=getChild<LLButton>(BTN_BLOCK); + button->setEnabled(TRUE); +} + +void LLFloaterExperienceProfile::experienceForgotten() +{ + LLButton* button=getChild<LLButton>(BTN_ALLOW); + button->setEnabled(TRUE); + + button=getChild<LLButton>(BTN_FORGET); + button->setEnabled(FALSE); + + button=getChild<LLButton>(BTN_BLOCK); + button->setEnabled(TRUE); +} + +void LLFloaterExperienceProfile::experienceBlocked() +{ + LLButton* button=getChild<LLButton>(BTN_ALLOW); + button->setEnabled(TRUE); + + button=getChild<LLButton>(BTN_FORGET); + button->setEnabled(TRUE); + + button=getChild<LLButton>(BTN_BLOCK); + button->setEnabled(FALSE); +} + +void LLFloaterExperienceProfile::onClose( bool app_quitting ) +{ + LLEventPumps::instance().obtain("experience_permission").stopListening(mExperienceId.asString()+"-profile"); + LLFloater::onClose(app_quitting); +} diff --git a/indra/newview/llfloaterexperienceprofile.h b/indra/newview/llfloaterexperienceprofile.h index feaff0547e..83ad75913f 100644 --- a/indra/newview/llfloaterexperienceprofile.h +++ b/indra/newview/llfloaterexperienceprofile.h @@ -54,10 +54,13 @@ public: LLUUID getExperienceId() const { return mExperienceId; } void setPreferences( const LLSD& content ); + + void refreshExperience(const LLSD& experience); void onSaveComplete( const LLSD& content ); virtual BOOL canClose(); + virtual void onClose(bool app_quitting); protected: void onClickEdit(); void onClickPermission(const char* permission); @@ -70,12 +73,18 @@ protected: void changeToView(); + void experienceForgotten(); + void experienceBlocked(); + void experienceAllowed(); + static void experienceCallback(LLHandle<LLFloaterExperienceProfile> handle, const LLSD& experience); + static bool experiencePermission(LLHandle<LLFloaterExperienceProfile> handle, const LLSD& permission); BOOL postBuild(); bool setMaturityString(U8 maturity, LLTextBox* child, LLComboBox* combo); bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response, PostSaveAction action); void doSave( int success_action ); + void updatePermission( const LLSD& permission ); LLUUID mExperienceId; LLSD mExperienceDetails; int mSaveCompleteAction; diff --git a/indra/newview/llfloaterexperiences.cpp b/indra/newview/llfloaterexperiences.cpp index 57f08742be..58ec4afd7c 100644 --- a/indra/newview/llfloaterexperiences.cpp +++ b/indra/newview/llfloaterexperiences.cpp @@ -7,6 +7,7 @@ #include "lltabcontainer.h" #include "lltrans.h" #include "llexperiencecache.h" +#include "llevents.h" class LLExperienceListResponder : public LLHTTPClient::Responder @@ -71,9 +72,11 @@ BOOL LLFloaterExperiences::postBuild() addTab("Recent_Experiences_Tab", false); resizeToTabs(); - refreshContents(); - - return TRUE; + + LLEventPumps::instance().obtain("experience_permission").listen("LLFloaterExperiences", + boost::bind(&LLFloaterExperiences::updatePermissions, this, _1)); + + return FALSE; } void LLFloaterExperiences::clearFromRecent(const LLSD& ids) @@ -157,3 +160,77 @@ void LLFloaterExperiences::refreshContents() } } } + +void LLFloaterExperiences::onOpen( const LLSD& key ) +{ + LLViewerRegion* region = gAgent.getRegion(); + if(region) + { + if(region->capabilitiesReceived()) + { + refreshContents(); + return; + } + region->setCapabilitiesReceivedCallback(boost::bind(&LLFloaterExperiences::refreshContents, this)); + return; + } +} + +bool LLFloaterExperiences::updatePermissions( const LLSD& permission ) +{ + LLTabContainer* tabs = getChild<LLTabContainer>("xp_tabs"); + LLUUID experience; + std::string permission_string; + if(permission.has("experience")) + { + experience = permission["experience"].asUUID(); + permission_string = permission[experience.asString()]["permission"].asString(); + + } + LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName("Allowed_Experiences_Tab"); + if(tab) + { + if(permission.has("experiences")) + { + tab->setExperienceList(permission["experiences"]); + } + else if(experience.notNull()) + { + if(permission_string != "Allow") + { + tab->removeExperience(experience); + } + else + { + tab->addExperience(experience); + } + } + } + + tab = (LLPanelExperiences*)tabs->getPanelByName("Blocked_Experiences_Tab"); + if(tab) + { + if(permission.has("blocked")) + { + tab->setExperienceList(permission["blocked"]); + } + else if(experience.notNull()) + { + if(permission_string != "Block") + { + tab->removeExperience(experience); + } + else + { + tab->addExperience(experience); + } + } + } + return false; +} + +void LLFloaterExperiences::onClose( bool app_quitting ) +{ + LLEventPumps::instance().obtain("experience_permission").stopListening("LLFloaterExperiences"); + LLFloater::onClose(app_quitting); +} diff --git a/indra/newview/llfloaterexperiences.h b/indra/newview/llfloaterexperiences.h index 01a0f4c551..27b453042b 100644 --- a/indra/newview/llfloaterexperiences.h +++ b/indra/newview/llfloaterexperiences.h @@ -33,21 +33,19 @@ class LLFloaterExperiences : public LLFloater { public: - LLFloaterExperiences(const LLSD& data); + LLFloaterExperiences(const LLSD& data); + virtual void onClose(bool app_quitting); + virtual void onOpen(const LLSD& key); +protected: void clearFromRecent(const LLSD& ids); void resizeToTabs(); - -protected: /*virtual*/ BOOL postBuild(); - void refreshContents(); - - - void setupRecentTabs(); void addTab(const std::string& name, bool select); + bool updatePermissions(const LLSD& permission); private: diff --git a/indra/newview/llpanelexperiences.cpp b/indra/newview/llpanelexperiences.cpp index 67ce3d3aa6..a057e8440f 100644 --- a/indra/newview/llpanelexperiences.cpp +++ b/indra/newview/llpanelexperiences.cpp @@ -67,10 +67,28 @@ void LLPanelExperiences::removeExperiences( const LLSD& ids ) LLSD::array_const_iterator it = ids.beginArray(); for( /**/ ; it != ids.endArray(); ++it) { - mExperiencesList->removeItemByUUID(it->asUUID()); + removeExperience(it->asUUID()); } } +void LLPanelExperiences::removeExperience( const LLUUID& id ) +{ + mExperiencesList->removeItemByUUID(id); +} + +void LLPanelExperiences::addExperience( const LLUUID& id ) +{ + if(!mExperiencesList->getItemByValue(id)) + { + LLExperienceItem* item = new LLExperienceItem(); + + item->init(id); + mExperiencesList->addItem(item, id); + } +} + + + LLExperienceItem::LLExperienceItem() { diff --git a/indra/newview/llpanelexperiences.h b/indra/newview/llpanelexperiences.h index 45773adda9..df35d8b53b 100644 --- a/indra/newview/llpanelexperiences.h +++ b/indra/newview/llpanelexperiences.h @@ -61,6 +61,8 @@ public: LLExperienceItem* getSelectedExperienceItem(); void removeExperiences( const LLSD& ids ); + void removeExperience( const LLUUID& id); + void addExperience( const LLUUID& id); protected: private: diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d7dffc5016..47644d2c6f 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -6343,6 +6343,12 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) return false; } + LLUUID experience; + if(notification["payload"].has("experience")) + { + experience = notification["payload"]["experience"].asUUID(); + } + // check whether permissions were granted or denied BOOL allowed = TRUE; // the "yes/accept" button is the first button in the template, making it button 0 @@ -6351,7 +6357,17 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) { new_questions = 0; allowed = FALSE; - } + } + else if(experience.notNull()) + { + LLSD permission; + LLSD data; + permission["permission"]="Allow"; + + data[experience.asString()]=permission; + data["experience"]=experience; + LLEventPumps::instance().obtain("experience_permission").post(data); + } LLUUID task_id = notification["payload"]["task_id"].asUUID(); LLUUID item_id = notification["payload"]["item_id"].asUUID(); @@ -6381,7 +6397,7 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) if ( response["BlockExperience"] ) { - if(notification["payload"].has("experience")) + if(experience.notNull()) { LLViewerRegion* region = gAgent.getRegion(); if (!region) @@ -6394,8 +6410,11 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) LLSD data; permission["permission"]="Block"; - data[notification["payload"]["experience"].asString()]=permission; + data[experience.asString()]=permission; LLHTTPClient::put(lookup_url, data, NULL); + + data["experience"]=experience; + LLEventPumps::instance().obtain("experience_permission").post(data); } } |