From f6652b3c02ff58a4476a7fbfc78c30d2cae3b6f0 Mon Sep 17 00:00:00 2001 From: Cinders <cinder@cinderblocks.biz> Date: Sat, 15 Aug 2015 09:55:23 -0600 Subject: [PATCH] De-yap default permissions floaters --- indra/llui/llfloater.h | 2 +- indra/newview/llfloaterperms.cpp | 162 +++++++----------- indra/newview/llfloaterperms.h | 44 ++--- indra/newview/llstartup.cpp | 5 +- indra/newview/llviewerregion.cpp | 2 - .../default/xui/en/floater_perms_default.xml | 1 + 6 files changed, 85 insertions(+), 131 deletions(-) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index de2896d5d6..cb02a646d4 100755 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -431,7 +431,7 @@ public: // Public so external views or floaters can watch for this floater opening commit_signal_t mOpenSignal; - // Called when floater is closed, passes app_qitting as LLSD() + // Called when floater is closed, passes app_qutting as LLSD() // Public so external views or floaters can watch for this floater closing commit_signal_t mCloseSignal; diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 88f4a1f625..f9953002b6 100755 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -26,19 +26,54 @@ */ #include "llviewerprecompiledheaders.h" -#include "llcheckboxctrl.h" #include "llfloaterperms.h" -#include "llviewercontrol.h" -#include "llviewerwindow.h" -#include "lluictrlfactory.h" -#include "llpermissions.h" + #include "llagent.h" -#include "llviewerregion.h" +#include "llfloaterreg.h" #include "llnotificationsutil.h" +#include "llpermissions.h" #include "llsdserialize.h" +#include "lluictrlfactory.h" +#include "llviewercontrol.h" +#include "llviewerregion.h" +#include "llviewerwindow.h" + +// String equivalents of enum Categories - initialization order must match enum order! +const std::array<std::string, 6> LLFloaterPermsDefault::sCategoryNames {{ + "Objects", + "Uploads", + "Scripts", + "Notecards", + "Gestures", + "Wearables" +}}; + +// Oh hi! I'm a caps responder. I'm here because thing +class LLFloaterPermsResponder : public LLHTTPClient::Responder +{ +public: + LLFloaterPermsResponder() : LLHTTPClient::Responder() {} + +private: + void httpFailure() + { + const std::string& reason = getReason(); + //LLNotificationsUtil::add("DefaultObjectPermissions", LLSD().with("REASON", reason)); + // This happens often enough to be irritating... Let's just drop it into the log. + LL_WARNS("ObjectPermissions") << "There was a problem saving the default object permissions: " << reason << LL_ENDL; + } + + void httpSuccess() + { + // Since we have had a successful POST call be sure to display the next error message + // even if it is the same as a previous one. + LL_INFOS("ObjectPermissionsFloater") << "Default permissions successfully sent to simulator" << LL_ENDL; + } +}; + -LLFloaterPerms::LLFloaterPerms(const LLSD& seed) -: LLFloater(seed) +LLFloaterPerms::LLFloaterPerms(const LLSD& key) +: LLFloater(key) { } @@ -48,19 +83,19 @@ BOOL LLFloaterPerms::postBuild() } //static -U32 LLFloaterPerms::getGroupPerms(std::string prefix) +U32 LLFloaterPerms::getGroupPerms(const std::string& prefix) { return gSavedSettings.getBOOL(prefix+"ShareWithGroup") ? PERM_COPY | PERM_MOVE | PERM_MODIFY : PERM_NONE; } //static -U32 LLFloaterPerms::getEveryonePerms(std::string prefix) +U32 LLFloaterPerms::getEveryonePerms(const std::string& prefix) { return gSavedSettings.getBOOL(prefix+"EveryoneCopy") ? PERM_COPY : PERM_NONE; } //static -U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix) +U32 LLFloaterPerms::getNextOwnerPerms(const std::string& prefix) { U32 flags = PERM_MOVE; if ( gSavedSettings.getBOOL(prefix+"NextOwnerCopy") ) @@ -78,48 +113,15 @@ U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix) return flags; } -//static -U32 LLFloaterPerms::getNextOwnerPermsInverted(std::string prefix) -{ - // Sets bits for permissions that are off - U32 flags = PERM_MOVE; - if ( !gSavedSettings.getBOOL(prefix+"NextOwnerCopy") ) - { - flags |= PERM_COPY; - } - if ( !gSavedSettings.getBOOL(prefix+"NextOwnerModify") ) - { - flags |= PERM_MODIFY; - } - if ( !gSavedSettings.getBOOL(prefix+"NextOwnerTransfer") ) - { - flags |= PERM_TRANSFER; - } - return flags; -} - -static bool mCapSent = false; -LLFloaterPermsDefault::LLFloaterPermsDefault(const LLSD& seed) - : LLFloater(seed) +LLFloaterPermsDefault::LLFloaterPermsDefault(const LLSD& key) +: LLFloater(key) { mCommitCallbackRegistrar.add("PermsDefault.Copy", boost::bind(&LLFloaterPermsDefault::onCommitCopy, this, _2)); mCommitCallbackRegistrar.add("PermsDefault.OK", boost::bind(&LLFloaterPermsDefault::onClickOK, this)); mCommitCallbackRegistrar.add("PermsDefault.Cancel", boost::bind(&LLFloaterPermsDefault::onClickCancel, this)); } - -// String equivalents of enum Categories - initialization order must match enum order! -const std::string LLFloaterPermsDefault::sCategoryNames[CAT_LAST] = -{ - "Objects", - "Uploads", - "Scripts", - "Notecards", - "Gestures", - "Wearables" -}; - BOOL LLFloaterPermsDefault::postBuild() { if(!gSavedSettings.getBOOL("DefaultUploadPermissionsConverted")) @@ -134,7 +136,7 @@ BOOL LLFloaterPermsDefault::postBuild() mCloseSignal.connect(boost::bind(&LLFloaterPermsDefault::cancel, this)); - refresh(); + reload(); return true; } @@ -154,70 +156,37 @@ void LLFloaterPermsDefault::onClickCancel() void LLFloaterPermsDefault::onCommitCopy(const LLSD& user_data) { // Implements fair use - std::string prefix = user_data.asString(); + const std::string& prefix = user_data.asString(); BOOL copyable = gSavedSettings.getBOOL(prefix+"NextOwnerCopy"); if(!copyable) { gSavedSettings.setBOOL(prefix+"NextOwnerTransfer", TRUE); } - LLCheckBoxCtrl* xfer = getChild<LLCheckBoxCtrl>(prefix+"_transfer"); + LLUICtrl* xfer = getChild<LLUICtrl>(prefix+"_transfer"); xfer->setEnabled(copyable); } -class LLFloaterPermsResponder : public LLHTTPClient::Responder +//static +void LLFloaterPermsDefault::setCapsReceivedCallback(LLViewerRegion* regionp) { -public: - LLFloaterPermsResponder(): LLHTTPClient::Responder() {} -private: - static std::string sPreviousReason; - - void httpFailure() - { - const std::string& reason = getReason(); - // Do not display the same error more than once in a row - if (reason != sPreviousReason) - { - sPreviousReason = reason; - LLSD args; - args["REASON"] = reason; - LLNotificationsUtil::add("DefaultObjectPermissions", args); - } - } - - void httpSuccess() - { - // Since we have had a successful POST call be sure to display the next error message - // even if it is the same as a previous one. - sPreviousReason = ""; - LLFloaterPermsDefault::setCapSent(true); - LL_INFOS("ObjectPermissionsFloater") << "Default permissions successfully sent to simulator" << LL_ENDL; - } -}; - - std::string LLFloaterPermsResponder::sPreviousReason; - -void LLFloaterPermsDefault::sendInitialPerms() -{ - if(!mCapSent) - { - updateCap(); - } + LLFloaterPermsDefault* floater = dynamic_cast<LLFloaterPermsDefault*>(LLFloaterReg::getInstance("perms_default")); + regionp->setCapabilitiesReceivedCallback(boost::bind(&LLFloaterPermsDefault::updateCap, floater)); } void LLFloaterPermsDefault::updateCap() { - std::string object_url = gAgent.getRegion()->getCapability("AgentPreferences"); + const std::string& object_url = gAgent.getRegion()->getCapability("AgentPreferences"); if(!object_url.empty()) { LLSD report = LLSD::emptyMap(); report["default_object_perm_masks"]["Group"] = - (LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[CAT_OBJECTS]); + (LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[0]); report["default_object_perm_masks"]["Everyone"] = - (LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[CAT_OBJECTS]); + (LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[0]); report["default_object_perm_masks"]["NextOwner"] = - (LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[CAT_OBJECTS]); + (LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[0]); { LL_DEBUGS("ObjectPermissionsFloater") << "Sending default permissions to '" @@ -235,16 +204,11 @@ void LLFloaterPermsDefault::updateCap() } } -void LLFloaterPermsDefault::setCapSent(bool cap_sent) -{ - mCapSent = cap_sent; -} - void LLFloaterPermsDefault::ok() { // Changes were already applied automatically to saved settings. // Refreshing internal values makes it official. - refresh(); + reload(); // We know some setting has changed but not which one. Just in case it was a setting for // object permissions tell the server what the values are. @@ -253,7 +217,7 @@ void LLFloaterPermsDefault::ok() void LLFloaterPermsDefault::cancel() { - for (U32 iter = CAT_OBJECTS; iter < CAT_LAST; iter++) + for (U32 iter = 0; iter < sCategoryNames.size() ; iter++) { gSavedSettings.setBOOL(sCategoryNames[iter]+"NextOwnerCopy", mNextOwnerCopy[iter]); gSavedSettings.setBOOL(sCategoryNames[iter]+"NextOwnerModify", mNextOwnerModify[iter]); @@ -263,9 +227,9 @@ void LLFloaterPermsDefault::cancel() } } -void LLFloaterPermsDefault::refresh() +void LLFloaterPermsDefault::reload() { - for (U32 iter = CAT_OBJECTS; iter < CAT_LAST; iter++) + for (U32 iter = 0; iter < sCategoryNames.size(); iter++) { mShareWithGroup[iter] = gSavedSettings.getBOOL(sCategoryNames[iter]+"ShareWithGroup"); mEveryoneCopy[iter] = gSavedSettings.getBOOL(sCategoryNames[iter]+"EveryoneCopy"); diff --git a/indra/newview/llfloaterperms.h b/indra/newview/llfloaterperms.h index 2bb0a19dc1..a5af1faece 100755 --- a/indra/newview/llfloaterperms.h +++ b/indra/newview/llfloaterperms.h @@ -30,6 +30,8 @@ #include "llfloater.h" +class LLViewerRegion; + class LLFloaterPerms : public LLFloater { friend class LLFloaterReg; @@ -38,55 +40,41 @@ public: /*virtual*/ BOOL postBuild(); // Convenience methods to get current permission preference bitfields from saved settings: - static U32 getEveryonePerms(std::string prefix=""); // prefix + "EveryoneCopy" - static U32 getGroupPerms(std::string prefix=""); // prefix + "ShareWithGroup" - static U32 getNextOwnerPerms(std::string prefix=""); // bitfield for prefix + "NextOwner" + "Copy", "Modify", and "Transfer" - static U32 getNextOwnerPermsInverted(std::string prefix=""); + static U32 getEveryonePerms(const std::string& prefix=""); // prefix + "EveryoneCopy" + static U32 getGroupPerms(const std::string& prefix=""); // prefix + "ShareWithGroup" + static U32 getNextOwnerPerms(const std::string& prefix=""); // bitfield for prefix + "NextOwner" + "Copy", "Modify", and "Transfer" private: LLFloaterPerms(const LLSD& seed); }; + class LLFloaterPermsDefault : public LLFloater { friend class LLFloaterReg; - public: - /*virtual*/ BOOL postBuild(); + BOOL postBuild() override; void ok(); void cancel(); void onClickOK(); void onClickCancel(); void onCommitCopy(const LLSD& user_data); - static void sendInitialPerms(); - static void updateCap(); - static void setCapSent(bool cap_sent); - -// Update instantiation of sCategoryNames in the .cpp file to match if you change this! -enum Categories -{ - CAT_OBJECTS, - CAT_UPLOADS, - CAT_SCRIPTS, - CAT_NOTECARDS, - CAT_GESTURES, - CAT_WEARABLES, - CAT_LAST -}; + void updateCap(); + static void setCapsReceivedCallback(LLViewerRegion* regionp); private: LLFloaterPermsDefault(const LLSD& seed); - void refresh(); + void reload(); - static const std::string sCategoryNames[CAT_LAST]; + static const std::array<std::string, 6> sCategoryNames; // cached values only for implementing cancel. - bool mShareWithGroup[CAT_LAST]; - bool mEveryoneCopy[CAT_LAST]; - bool mNextOwnerCopy[CAT_LAST]; - bool mNextOwnerModify[CAT_LAST]; - bool mNextOwnerTransfer[CAT_LAST]; + bool mShareWithGroup[6]; + bool mEveryoneCopy[6]; + bool mNextOwnerCopy[6]; + bool mNextOwnerModify[6]; + bool mNextOwnerTransfer[6]; }; #endif diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0987ad7fd5..45213b3f8e 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -73,6 +73,7 @@ #include "llmoveview.h" #include "llfloaterimcontainer.h" #include "llfloaterimnearbychat.h" +#include "llfloaterperms.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llpersistentnotificationstorage.h" @@ -1323,10 +1324,12 @@ bool idle_startup() LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(gFirstSimHandle); LL_INFOS("AppInit") << "Adding initial simulator " << regionp->getOriginGlobal() << LL_ENDL; + LLFloaterPermsDefault::setCapsReceivedCallback(regionp); + LL_DEBUGS("CrossingCaps") << "Calling setSeedCapability from init_idle(). Seed cap == " << gFirstSimSeedCap << LL_ENDL; regionp->setSeedCapability(gFirstSimSeedCap); - LL_DEBUGS("AppInit") << "Waiting for seed grant ...." << LL_ENDL; + LL_DEBUGS("AppInit") << "Waiting for seed grant..." << LL_ENDL; display_startup(); // Set agent's initial region to be the one we just created. gAgent.setRegion(regionp); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 7c8303d844..aca70118e2 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -3105,8 +3105,6 @@ void LLViewerRegion::setCapabilitiesReceived(bool received) { mCapabilitiesReceivedSignal(getRegionID()); - LLFloaterPermsDefault::sendInitialPerms(); - // This is a single-shot signal. Forget callbacks to save resources. mCapabilitiesReceivedSignal.disconnect_all_slots(); } diff --git a/indra/newview/skins/default/xui/en/floater_perms_default.xml b/indra/newview/skins/default/xui/en/floater_perms_default.xml index ceb260fffb..5acd528a0d 100644 --- a/indra/newview/skins/default/xui/en/floater_perms_default.xml +++ b/indra/newview/skins/default/xui/en/floater_perms_default.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater legacy_header_height="18" + single_instance="true" height="250" layout="topleft" name="perms default" -- GitLab