summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llagent.cpp156
-rw-r--r--indra/newview/llagent.h10
-rw-r--r--indra/newview/llviewermessage.cpp2
-rw-r--r--indra/newview/llviewerregion.cpp1
4 files changed, 148 insertions, 21 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 8dd0b06ed2..ebff73debf 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -47,7 +47,9 @@
#include "llfloatercamera.h"
#include "llfloaterimcontainer.h"
#include "llfloaterperms.h"
+#include "llfloaterpreference.h"
#include "llfloaterreg.h"
+#include "llfloatersnapshot.h"
#include "llfloatertools.h"
#include "llgroupactions.h"
#include "llgroupmgr.h"
@@ -4334,15 +4336,143 @@ void LLAgent::sendAgentDataUpdateRequest()
void LLAgent::sendAgentUserInfoRequest()
{
- if(getID().isNull())
- return; // not logged in
- gMessageSystem->newMessageFast(_PREHASH_UserInfoRequest);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
- sendReliableMessage();
+ std::string cap;
+
+ if (getID().isNull())
+ return; // not logged in
+
+ if (mRegionp)
+ cap = mRegionp->getCapability("UserInfo");
+
+ if (!cap.empty())
+ {
+ LLCoros::instance().launch("requestAgentUserInfoCoro",
+ boost::bind(&LLAgent::requestAgentUserInfoCoro, this, cap));
+ }
+ else
+ {
+ sendAgentUserInfoRequestMessage();
+ }
}
+void LLAgent::requestAgentUserInfoCoro(std::string capurl)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("requestAgentUserInfoCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
+ LLCore::HttpHeaders::ptr_t httpHeaders;
+
+ httpOpts->setFollowRedirects(true);
+
+ LLSD result = httpAdapter->getAndSuspend(httpRequest, capurl, httpOpts, httpHeaders);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ LL_WARNS("UserInfo") << "Failed to get user information." << LL_ENDL;
+ return;
+ }
+ else if (!result["success"].asBoolean())
+ {
+ LL_WARNS("UserInfo") << "Failed to get user information: " << result["message"] << LL_ENDL;
+ return;
+ }
+
+ bool im_via_email;
+ std::string email;
+ std::string dir_visibility;
+
+ im_via_email = result["im_via_email"].asBoolean();
+ email = result["email"].asString();
+ dir_visibility = result["directory_visibility"].asString();
+
+ // TODO: This should probably be changed. I'm not entirely comfortable
+ // having LLAgent interact directly with the UI in this way.
+ LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email);
+ LLFloaterSnapshot::setAgentEmail(email);
+}
+
+void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& directory_visibility)
+{
+ std::string cap;
+
+ if (getID().isNull())
+ return; // not logged in
+
+ if (mRegionp)
+ cap = mRegionp->getCapability("UserInfo");
+
+ if (!cap.empty())
+ {
+ LLCoros::instance().launch("updateAgentUserInfoCoro",
+ boost::bind(&LLAgent::updateAgentUserInfoCoro, this, cap, im_via_email, directory_visibility));
+ }
+ else
+ {
+ sendAgentUpdateUserInfoMessage(im_via_email, directory_visibility);
+ }
+}
+
+
+void LLAgent::updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("requestAgentUserInfoCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
+ LLCore::HttpHeaders::ptr_t httpHeaders;
+
+ httpOpts->setFollowRedirects(true);
+ LLSD body(LLSDMap
+ ("dir_visibility", LLSD::String(directory_visibility))
+ ("im_via_email", LLSD::Boolean(im_via_email)));
+
+ LLSD result = httpAdapter->postAndSuspend(httpRequest, capurl, body, httpOpts, httpHeaders);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ LL_WARNS("UserInfo") << "Failed to set user information." << LL_ENDL;
+ }
+ else if (!result["success"].asBoolean())
+ {
+ LL_WARNS("UserInfo") << "Failed to set user information: " << result["message"] << LL_ENDL;
+ }
+}
+
+// deprecated:
+// May be removed when UserInfo cap propagates to all simhosts in grid
+void LLAgent::sendAgentUserInfoRequestMessage()
+{
+ gMessageSystem->newMessageFast(_PREHASH_UserInfoRequest);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
+ sendReliableMessage();
+}
+
+void LLAgent::sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility)
+{
+ gMessageSystem->newMessageFast(_PREHASH_UpdateUserInfo);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_UserData);
+ gMessageSystem->addBOOLFast(_PREHASH_IMViaEMail, im_via_email);
+ gMessageSystem->addString("DirectoryVisibility", directory_visibility);
+ gAgent.sendReliableMessage();
+
+}
+// end deprecated
+//------
+
void LLAgent::observeFriends()
{
if(!mFriendObserver)
@@ -4410,18 +4540,6 @@ const void LLAgent::getTeleportSourceSLURL(LLSLURL& slurl) const
slurl = *mTeleportSourceSLURL;
}
-void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& directory_visibility )
-{
- gMessageSystem->newMessageFast(_PREHASH_UpdateUserInfo);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_UserData);
- gMessageSystem->addBOOLFast(_PREHASH_IMViaEMail, im_via_email);
- gMessageSystem->addString("DirectoryVisibility", directory_visibility);
- gAgent.sendReliableMessage();
-}
-
// static
void LLAgent::dumpGroupInfo()
{
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index b5da5e9062..4bb4d317e8 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -912,9 +912,17 @@ public:
void sendReliableMessage();
void sendAgentDataUpdateRequest();
void sendAgentUserInfoRequest();
- // IM to Email and Online visibility
+
+// IM to Email and Online visibility
void sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility);
+private:
+ void requestAgentUserInfoCoro(std::string capurl);
+ void updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility);
+ // DEPRECATED: may be removed when User Info cap propagates
+ void sendAgentUserInfoRequestMessage();
+ void sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility);
+
//--------------------------------------------------------------------
// Receive
//--------------------------------------------------------------------
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 4848101750..98093344a9 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -7259,7 +7259,7 @@ void send_places_query(const LLUUID& query_id,
gAgent.sendReliableMessage();
}
-
+// Deprecated in favor of cap "UserInfo"
void process_user_info_reply(LLMessageSystem* msg, void**)
{
LLUUID agent_id;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 3fd2af87de..3f479802aa 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2896,6 +2896,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
capabilityNames.append("UpdateScriptAgent");
capabilityNames.append("UpdateScriptTask");
capabilityNames.append("UploadBakedTexture");
+ capabilityNames.append("UserInfo");
capabilityNames.append("ViewerAsset");
capabilityNames.append("ViewerMetrics");
capabilityNames.append("ViewerStartAuction");