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.meow-7.2.2
parent
fedfbbb8d8
commit
4218819951
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue