summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2010-04-15 16:22:15 -0700
committerJames Cook <james@lindenlab.com>2010-04-15 16:22:15 -0700
commit4218819951a5caa1499e79d8bd4f1bf08fe3b3cc (patch)
treecb9a4b19346e9e04d89098681ea67e20633c7353 /indra
parentfedfbbb8d8696044cace410365e348b20a1e2420 (diff)
DEV-47529 Viewer looks up display names via a sim cap
Squire asked me to route display name lookups via a simulator capability using HTTP GET. This buys us authentication until the data services team can implement a public-facing authenticating web service for People API.
Diffstat (limited to 'indra')
-rw-r--r--indra/llmessage/llavatarnamecache.cpp87
-rw-r--r--indra/llmessage/llavatarnamecache.h19
-rw-r--r--indra/newview/llstartup.cpp3
-rw-r--r--indra/newview/llviewerregion.cpp16
4 files changed, 35 insertions, 90 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index bb1f6fdb3a..8268624b84 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -50,10 +50,9 @@ namespace LLAvatarNameCache
// Base lookup URL for name service.
// On simulator, loaded from indra.xml
- // On viewer, sent down from login.cgi
- // from login.cgi
- // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/"
- std::string sNameServiceURL;
+ // On viewer, usually a simulator capability (at People API team's request)
+ // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/agents/"
+ std::string sNameLookupURL;
// accumulated agent IDs for next query against service
typedef std::set<LLUUID> ask_queue_t;
@@ -155,7 +154,7 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row)
LLAvatarName av_name;
av_name.mSLID = row["sl_id"].asString();
av_name.mDisplayName = row["display_name"].asString();
- //av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean();
+ av_name.mIsDisplayNameDefault = row["is_display_name_default"].asBoolean();
U32 now = (U32)LLFrameTimer::getTotalSeconds();
S32 seconds_until_expires = row["seconds_until_display_name_expires"].asInteger();
@@ -173,23 +172,6 @@ void LLAvatarNameCache::processNameFromService(const LLSD& row)
av_name.mDisplayName = av_name.mSLID;
}
- // HACK: Legacy users have '.' in their SLID
- // JAMESDEBUG TODO: change to using is_display_name_default once that works
- std::string mangled_name = av_name.mDisplayName;
- for (U32 i = 0; i < mangled_name.size(); i++)
- {
- char c = mangled_name[i];
- if (c == ' ')
- {
- mangled_name[i] = '.';
- }
- else
- {
- mangled_name[i] = tolower(c);
- }
- }
- av_name.mIsDisplayNameDefault = (mangled_name == av_name.mSLID);
-
// add to cache
LLUUID agent_id = row["id"].asUUID();
sCache[agent_id] = av_name;
@@ -227,8 +209,8 @@ void LLAvatarNameCache::requestNames()
if (url.empty())
{
// ...starting new request
- url += sNameServiceURL;
- url += "agents/?ids=";
+ url += sNameLookupURL;
+ url += "?ids=";
}
else
{
@@ -253,9 +235,8 @@ void LLAvatarNameCache::requestNames()
}
}
-void LLAvatarNameCache::initClass(const std::string& name_service_url)
+void LLAvatarNameCache::initClass()
{
- setNameServiceURL(name_service_url);
}
void LLAvatarNameCache::cleanupClass()
@@ -270,9 +251,9 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr)
{
}
-void LLAvatarNameCache::setNameServiceURL(const std::string& name_service_url)
+void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url)
{
- sNameServiceURL = name_service_url;
+ sNameLookupURL = name_lookup_url;
}
void LLAvatarNameCache::idle()
@@ -292,6 +273,12 @@ void LLAvatarNameCache::idle()
eraseExpired();
}
+ if (sNameLookupURL.empty())
+ {
+ // ...viewer has not yet received capability from region
+ return;
+ }
+
if (sAskQueue.empty())
{
return;
@@ -392,50 +379,6 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
}
}
-// JAMESDEBUG TODO: Eliminate and only route changes through simulator
-class LLSetNameResponder : public LLHTTPClient::Responder
-{
-public:
- LLUUID mAgentID;
- LLAvatarNameCache::set_name_signal_t mSignal;
-
- LLSetNameResponder(const LLUUID& agent_id,
- const LLAvatarNameCache::set_name_slot_t& slot)
- : mAgentID(agent_id),
- mSignal()
- {
- mSignal.connect(slot);
- }
-
- /*virtual*/ void result(const LLSD& content)
- {
- // force re-fetch
- LLAvatarNameCache::sCache.erase(mAgentID);
-
- mSignal(true, "", content);
- }
-
- /*virtual*/ void error(U32 status, const std::string& reason)
- {
- llinfos << "LLSetNameResponder failed " << status
- << " reason " << reason << llendl;
-
- mSignal(false, reason, LLSD());
- }
-};
-
-// JAMESDEBUG TODO: Eliminate and only route changes through simulator
-void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id,
- const std::string& display_name,
- const set_name_slot_t& slot)
-{
- LLSD body;
- body["display_name"] = display_name;
-
- std::string url = sNameServiceURL + "agent/";
- url += agent_id.asString();
- LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id, slot));
-}
void LLAvatarNameCache::toggleDisplayNames()
{
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index a4e101899a..111e56433b 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -42,13 +42,14 @@ class LLUUID;
namespace LLAvatarNameCache
{
- void initClass(const std::string& name_service_url);
+ void initClass();
void cleanupClass();
void importFile(std::istream& istr);
void exportFile(std::ostream& ostr);
- void setNameServiceURL(const std::string& name_service_url);
+ // On the viewer, usually a simulator capabilitity
+ void setNameLookupURL(const std::string& name_lookup_url);
// Periodically makes a batch request for display names not already in
// cache. Call once per frame.
@@ -68,20 +69,6 @@ namespace LLAvatarNameCache
// If name information is in cache, callback will be called immediately.
void get(const LLUUID& agent_id, callback_slot_t slot);
- // JAMESDEBUG TODO: remove code to set display name, handle in
- // application layer because it's different for client and server
-
- // Callback types for setDisplayName() below
- typedef boost::signals2::signal<
- void (bool success, const std::string& reason, const LLSD& content)>
- set_name_signal_t;
- typedef set_name_signal_t::slot_type set_name_slot_t;
-
- // Sends an update to the server to change a display name
- // and calls back the application layer when done
- void setDisplayName(const LLUUID& agent_id, const std::string& display_name,
- const set_name_slot_t& slot);
-
// HACK: turn display names on and off
void toggleDisplayNames();
bool useDisplayNames();
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 8f5ad63cc3..18792950eb 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2772,8 +2772,7 @@ void LLStartUp::initNameCache()
// Load stored cache if possible
LLAppViewer::instance()->loadNameCache();
- // JAMESDEBUG TODO: won't need service url here, will use capability
- LLAvatarNameCache::initClass("http://pdp60.lindenlab.com:8000/");
+ LLAvatarNameCache::initClass();
}
void LLStartUp::cleanupNameCache()
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 8f43b6bcf7..2b907ee24a 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -34,7 +34,9 @@
#include "llviewerregion.h"
+// linden libraries
#include "indra_constants.h"
+#include "llavatarnamecache.h" // name lookup cap url
#include "llfloaterreg.h"
#include "llmath.h"
#include "llhttpclient.h"
@@ -173,6 +175,19 @@ public:
mRegion->showReleaseNotes();
}
}
+
+ // Avatar name lookup library needs to know who to ask
+ std::string name_lookup_url = mRegion->getCapability("GetDisplayNames");
+ // capabilities require URLs with slashes before query params, like:
+ // https://<host>:<port>/cap/<uuid>/?ids=<blah>
+ // but the caps are granted like:
+ // https://<host>:<port>/cap/<uuid>
+ U32 url_size = name_lookup_url.size();
+ if (url_size > 0 && name_lookup_url[url_size-1] != '/')
+ {
+ name_lookup_url += '/';
+ }
+ LLAvatarNameCache::setNameLookupURL(name_lookup_url);
if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
{
@@ -1474,6 +1489,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
capabilityNames.append("ObjectMediaNavigate");
capabilityNames.append("FetchLib");
capabilityNames.append("FetchLibDescendents");
+ capabilityNames.append("GetDisplayNames");
capabilityNames.append("GetTexture");
capabilityNames.append("GroupProposalBallot");
capabilityNames.append("HomeLocation");