Skip to content
Snippets Groups Projects
Commit e9257f03 authored by Rider Linden's avatar Rider Linden
Browse files

Object default perm floater

parent f7fa3b5f
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "llnotificationsutil.h" #include "llnotificationsutil.h"
#include "llsdserialize.h" #include "llsdserialize.h"
#include "llvoavatar.h" #include "llvoavatar.h"
#include "llcorehttputil.h"
LLFloaterPerms::LLFloaterPerms(const LLSD& seed) LLFloaterPerms::LLFloaterPerms(const LLSD& seed)
: LLFloater(seed) : LLFloater(seed)
...@@ -166,41 +167,6 @@ void LLFloaterPermsDefault::onCommitCopy(const LLSD& user_data) ...@@ -166,41 +167,6 @@ void LLFloaterPermsDefault::onCommitCopy(const LLSD& user_data)
xfer->setEnabled(copyable); 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() void LLFloaterPermsDefault::sendInitialPerms()
{ {
if(!mCapSent) if(!mCapSent)
...@@ -215,23 +181,8 @@ void LLFloaterPermsDefault::updateCap() ...@@ -215,23 +181,8 @@ void LLFloaterPermsDefault::updateCap()
if(!object_url.empty()) if(!object_url.empty())
{ {
LLSD report = LLSD::emptyMap(); LLCoros::instance().launch("LLFloaterPermsDefault::updateCapCoro",
report["default_object_perm_masks"]["Group"] = boost::bind(&LLFloaterPermsDefault::updateCapCoro, _1, object_url));
(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());
} }
else else
{ {
...@@ -239,6 +190,57 @@ void LLFloaterPermsDefault::updateCap() ...@@ -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) void LLFloaterPermsDefault::setCapSent(bool cap_sent)
{ {
mCapSent = cap_sent; mCapSent = cap_sent;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#define LL_LLFLOATERPERMPREFS_H #define LL_LLFLOATERPERMPREFS_H
#include "llfloater.h" #include "llfloater.h"
#include "lleventcoro.h"
#include "llcoros.h"
class LLFloaterPerms : public LLFloater class LLFloaterPerms : public LLFloater
{ {
...@@ -80,6 +82,8 @@ enum Categories ...@@ -80,6 +82,8 @@ enum Categories
void refresh(); void refresh();
static const std::string sCategoryNames[CAT_LAST]; static const std::string sCategoryNames[CAT_LAST];
static void LLFloaterPermsDefault::updateCapCoro(LLCoros::self& self, std::string url);
// cached values only for implementing cancel. // cached values only for implementing cancel.
bool mShareWithGroup[CAT_LAST]; bool mShareWithGroup[CAT_LAST];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment