Object default perm floater
parent
f7fa3b5f56
commit
e9257f034a
|
|
@ -37,6 +37,7 @@
|
|||
#include "llnotificationsutil.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llcorehttputil.h"
|
||||
|
||||
LLFloaterPerms::LLFloaterPerms(const LLSD& seed)
|
||||
: LLFloater(seed)
|
||||
|
|
@ -166,41 +167,6 @@ void LLFloaterPermsDefault::onCommitCopy(const LLSD& user_data)
|
|||
xfer->setEnabled(copyable);
|
||||
}
|
||||
|
||||
class LLFloaterPermsResponder : public LLHTTPClient::Responder
|
||||
{
|
||||
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()
|
||||
{
|
||||
//const LLSD& content = getContent();
|
||||
//dump_sequential_xml("perms_responder_result.xml", content);
|
||||
|
||||
// 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)
|
||||
|
|
@ -215,23 +181,8 @@ void LLFloaterPermsDefault::updateCap()
|
|||
|
||||
if(!object_url.empty())
|
||||
{
|
||||
LLSD report = LLSD::emptyMap();
|
||||
report["default_object_perm_masks"]["Group"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[CAT_OBJECTS]);
|
||||
report["default_object_perm_masks"]["Everyone"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[CAT_OBJECTS]);
|
||||
report["default_object_perm_masks"]["NextOwner"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[CAT_OBJECTS]);
|
||||
|
||||
{
|
||||
LL_DEBUGS("ObjectPermissionsFloater") << "Sending default permissions to '"
|
||||
<< object_url << "'\n";
|
||||
std::ostringstream sent_perms_log;
|
||||
LLSDSerialize::toPrettyXML(report, sent_perms_log);
|
||||
LL_CONT << sent_perms_log.str() << LL_ENDL;
|
||||
}
|
||||
|
||||
LLHTTPClient::post(object_url, report, new LLFloaterPermsResponder());
|
||||
LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro",
|
||||
boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -239,6 +190,57 @@ void LLFloaterPermsDefault::updateCap()
|
|||
}
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url)
|
||||
{
|
||||
static std::string previousReason;
|
||||
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
|
||||
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
|
||||
httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy));
|
||||
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
|
||||
|
||||
LLSD postData = LLSD::emptyMap();
|
||||
postData["default_object_perm_masks"]["Group"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getGroupPerms(sCategoryNames[CAT_OBJECTS]);
|
||||
postData["default_object_perm_masks"]["Everyone"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getEveryonePerms(sCategoryNames[CAT_OBJECTS]);
|
||||
postData["default_object_perm_masks"]["NextOwner"] =
|
||||
(LLSD::Integer)LLFloaterPerms::getNextOwnerPerms(sCategoryNames[CAT_OBJECTS]);
|
||||
|
||||
{
|
||||
LL_DEBUGS("ObjectPermissionsFloater") << "Sending default permissions to '"
|
||||
<< url << "'\n";
|
||||
std::ostringstream sent_perms_log;
|
||||
LLSDSerialize::toPrettyXML(postData, sent_perms_log);
|
||||
LL_CONT << sent_perms_log.str() << LL_ENDL;
|
||||
}
|
||||
|
||||
LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData);
|
||||
|
||||
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
|
||||
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
const std::string& reason = status.toString();
|
||||
// Do not display the same error more than once in a row
|
||||
if (reason != previousReason)
|
||||
{
|
||||
previousReason = reason;
|
||||
LLSD args;
|
||||
args["REASON"] = reason;
|
||||
LLNotificationsUtil::add("DefaultObjectPermissions", args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 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.
|
||||
previousReason.clear();
|
||||
LLFloaterPermsDefault::setCapSent(true);
|
||||
LL_INFOS("ObjectPermissionsFloater") << "Default permissions successfully sent to simulator" << LL_ENDL;
|
||||
}
|
||||
|
||||
void LLFloaterPermsDefault::setCapSent(bool cap_sent)
|
||||
{
|
||||
mCapSent = cap_sent;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#define LL_LLFLOATERPERMPREFS_H
|
||||
|
||||
#include "llfloater.h"
|
||||
#include "lleventcoro.h"
|
||||
#include "llcoros.h"
|
||||
|
||||
class LLFloaterPerms : public LLFloater
|
||||
{
|
||||
|
|
@ -80,6 +82,8 @@ private:
|
|||
void refresh();
|
||||
|
||||
static const std::string sCategoryNames[CAT_LAST];
|
||||
static void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url);
|
||||
|
||||
|
||||
// cached values only for implementing cancel.
|
||||
bool mShareWithGroup[CAT_LAST];
|
||||
|
|
|
|||
Loading…
Reference in New Issue