diff options
author | dolphin <dolphin@lindenlab.com> | 2013-09-03 10:14:24 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-09-03 10:14:24 -0700 |
commit | df437553ede576df4e6a1c5e4a2e177f7d8275c2 (patch) | |
tree | acb159c9f0859a2f1d895ab38a02f85c6ac13ecc /indra/newview | |
parent | d29268f331380eb89224c5b0168bf89bd0116422 (diff) |
Updated experience profile floater to have permission buttons
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterexperienceprofile.cpp | 151 | ||||
-rw-r--r-- | indra/newview/llfloaterexperienceprofile.h | 5 | ||||
-rwxr-xr-x | indra/newview/llviewerregion.cpp | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_experienceprofile.xml | 22 |
4 files changed, 169 insertions, 13 deletions
diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index 8e5a7a7588..895fd5ee4d 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -57,6 +57,9 @@ #define PNL_MRKT "marketplace panel" #define BTN_EDIT "edit_btn" +#define BTN_ALLOW "allow_btn" +#define BTN_FORGET "forget_btn" +#define BTN_BLOCK "block_btn" LLFloaterExperienceProfile::LLFloaterExperienceProfile(const LLSD& data) @@ -75,6 +78,29 @@ LLFloaterExperienceProfile::~LLFloaterExperienceProfile() } +class ExperiencePreferencesResponder : public LLHTTPClient::Responder +{ +public: + ExperiencePreferencesResponder(const LLHandle<LLFloaterExperienceProfile>& parent):mParent(parent) + { + } + + LLHandle<LLFloaterExperienceProfile> mParent; + + virtual void result(const LLSD& content) + { + LLFloaterExperienceProfile* parent=mParent.get(); + if(parent) + { + parent->setPreferences(content); + } + } + virtual void error(U32 status, const std::string& reason) + { + lldebugs << "ExperiencePreferencesResponder failed with code: " << status<< ", reason: " << reason << llendl; + } +}; + class IsAdminResponder : public LLHTTPClient::Responder { @@ -90,8 +116,27 @@ public: LLFloaterExperienceProfile* parent = mParent.get(); if(!parent) return; + + LLButton* edit=parent->getChild<LLButton>(BTN_EDIT); - parent->getChild<LLButton>(BTN_EDIT)->setVisible(content["status"].asBoolean()); + if(content.has("experience_ids")) + { + LLUUID id=parent->getKey().asUUID(); + const LLSD& xp_ids = content["experience_ids"]; + LLSD::array_const_iterator it = xp_ids.beginArray(); + while(it != xp_ids.endArray()) + { + if(it->asUUID() == id) + { + edit->setVisible(TRUE); + return; + } + ++it; + } + } + edit->setVisible(FALSE); + + //parent->getChild<LLButton>(BTN_EDIT)->setVisible(content["status"].asBoolean()); } virtual void error(U32 status, const std::string& reason) { @@ -115,10 +160,22 @@ BOOL LLFloaterExperienceProfile::postBuild() LLViewerRegion* region = gAgent.getRegion(); if (region) { - std::string lookup_url=region->getCapability("IsExperienceAdmin"); + // std::string lookup_url=region->getCapability("IsExperienceAdmin"); + // if(!lookup_url.empty()) + // { + // LLHTTPClient::get(lookup_url+"/"+mExperienceId.asString(), new IsAdminResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + // } + + std::string lookup_url=region->getCapability("GetAdminExperiences"); + if(!lookup_url.empty()) + { + LLHTTPClient::get(lookup_url, new IsAdminResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + } + + lookup_url=region->getCapability("ExperiencePreferences"); if(!lookup_url.empty()) { - LLHTTPClient::get(lookup_url+"/"+mExperienceId.asString(), new IsAdminResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + LLHTTPClient::get(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); } } } @@ -127,6 +184,9 @@ BOOL LLFloaterExperienceProfile::postBuild() childSetAction(BTN_EDIT, boost::bind(&LLFloaterExperienceProfile::onClickEdit, this)); + childSetAction(BTN_ALLOW, boost::bind(&LLFloaterExperienceProfile::onClickPermission, this, "Allow")); + childSetAction(BTN_FORGET, boost::bind(&LLFloaterExperienceProfile::onClickForget, this)); + childSetAction(BTN_BLOCK, boost::bind(&LLFloaterExperienceProfile::onClickPermission, this, "Block")); return TRUE; } @@ -145,6 +205,39 @@ void LLFloaterExperienceProfile::onClickEdit() } + +void LLFloaterExperienceProfile::onClickPermission(const char* perm) +{ + LLViewerRegion* region = gAgent.getRegion(); + if (!region) + return; + + std::string lookup_url=region->getCapability("ExperiencePreferences"); + if(lookup_url.empty()) + return; + LLSD permission; + LLSD data; + permission["permission"]=perm; + + data[mExperienceId.asString()]=permission; + LLHTTPClient::put(lookup_url, data, new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); + +} + + +void LLFloaterExperienceProfile::onClickForget() +{ + LLViewerRegion* region = gAgent.getRegion(); + if (!region) + return; + + std::string lookup_url=region->getCapability("ExperiencePreferences"); + if(lookup_url.empty()) + return; + + LLHTTPClient::del(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(getDerivedHandle<LLFloaterExperienceProfile>())); +} + bool LLFloaterExperienceProfile::setMaturityString( U8 maturity, LLTextBox* child ) { LLStyle::Params style; @@ -258,4 +351,54 @@ void LLFloaterExperienceProfile::refreshExperience( const LLSD& experience ) -}
\ No newline at end of file +} + +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); + return; + } + } + + for(LLSD::array_const_iterator it = blocked.beginArray(); it != blocked.endArray() ; ++it) + { + 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); + 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); +} diff --git a/indra/newview/llfloaterexperienceprofile.h b/indra/newview/llfloaterexperienceprofile.h index e19a63aca7..c486ca5f30 100644 --- a/indra/newview/llfloaterexperienceprofile.h +++ b/indra/newview/llfloaterexperienceprofile.h @@ -44,9 +44,12 @@ public: virtual ~LLFloaterExperienceProfile(); void setExperienceId( const LLUUID& experience_id ); + void setPreferences( const LLSD& content ); protected: - void onClickEdit(); + void onClickEdit(); + void onClickPermission(const char* permission); + void onClickForget(); static void experienceCallback(LLHandle<LLFloaterExperienceProfile> handle, const LLSD& experience); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e0eb8b5f46..af993943ce 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1601,7 +1601,11 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("GetAdminExperiences"); capabilityNames.append("GetCreatorExperiences"); capabilityNames.append("ExperiencePreferences"); +/* + DMH - Does not work, needs a modified people api to take the experience UUID capabilityNames.append("IsExperienceAdmin"); + capabilityNames.append("IsExperienceContributor"); +*/ capabilityNames.append("GetMesh"); capabilityNames.append("GetMetadata"); capabilityNames.append("GetObjectCost"); diff --git a/indra/newview/skins/default/xui/en/floater_experienceprofile.xml b/indra/newview/skins/default/xui/en/floater_experienceprofile.xml index 668a3bcc2e..58c0ed70ef 100644 --- a/indra/newview/skins/default/xui/en/floater_experienceprofile.xml +++ b/indra/newview/skins/default/xui/en/floater_experienceprofile.xml @@ -26,10 +26,6 @@ name="maturity_icon_adult"> "Parcel_R_Light" </floater.string> - <floater.string - name="forget_experience"> - "Forget" - </floater.string> <panel background_visible="true" follows="all" @@ -218,7 +214,7 @@ </layout_panel> <layout_panel follows="left|top|right" - height="69" + height="92" left="0" top="0" auto_resize="false" @@ -279,9 +275,9 @@ layout="topleft" name="edit_btn" top_pad="3" - width="80" - left="10" - visible="false"/> + width="120" + left="73" + visible="true"/> <button follows="bottom|left" height="23" @@ -289,6 +285,16 @@ layout="topleft" name="allow_btn" width="80" + top_pad="3" + left="10" + enabled="false"/> + <button + follows="bottom|left" + height="23" + label="Forget" + layout="topleft" + name="forget_btn" + width="80" top_pad="-23" left_pad="3" enabled="false"/> |