From df437553ede576df4e6a1c5e4a2e177f7d8275c2 Mon Sep 17 00:00:00 2001 From: dolphin Date: Tue, 3 Sep 2013 10:14:24 -0700 Subject: Updated experience profile floater to have permission buttons --- indra/newview/llfloaterexperienceprofile.cpp | 151 ++++++++++++++++++++- indra/newview/llfloaterexperienceprofile.h | 5 +- indra/newview/llviewerregion.cpp | 4 + .../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& parent):mParent(parent) + { + } + + LLHandle 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(BTN_EDIT); - parent->getChild(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(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())); + // } + + std::string lookup_url=region->getCapability("GetAdminExperiences"); + if(!lookup_url.empty()) + { + LLHTTPClient::get(lookup_url, new IsAdminResponder(getDerivedHandle())); + } + + lookup_url=region->getCapability("ExperiencePreferences"); if(!lookup_url.empty()) { - LLHTTPClient::get(lookup_url+"/"+mExperienceId.asString(), new IsAdminResponder(getDerivedHandle())); + LLHTTPClient::get(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(getDerivedHandle())); } } } @@ -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())); + +} + + +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())); +} + 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(BTN_ALLOW); + button->setEnabled(FALSE); + + button=getChild(BTN_FORGET); + button->setEnabled(TRUE); + + button=getChild(BTN_BLOCK); + button->setEnabled(TRUE); + return; + } + } + + for(LLSD::array_const_iterator it = blocked.beginArray(); it != blocked.endArray() ; ++it) + { + if(it->asUUID()==mExperienceId) + { + button=getChild(BTN_ALLOW); + button->setEnabled(TRUE); + + button=getChild(BTN_FORGET); + button->setEnabled(TRUE); + + button=getChild(BTN_BLOCK); + button->setEnabled(FALSE); + return; + } + } + + + button=getChild(BTN_ALLOW); + button->setEnabled(TRUE); + + button=getChild(BTN_FORGET); + button->setEnabled(FALSE); + + button=getChild(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 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" - - "Forget" - + width="120" + left="73" + visible="true"/>