STORM-797 FIXED Added parcel SLURL rendering with human readable parcel names.

- Added parcel info observer to LLUrlEntryParcel.
- Added notifying LLUrlEntryParcel by LLRemoteParcelInfoProcessor when parcel data arrives.
- Added notifying LLUrlEntryParcel about user login, changing host and viewer connection state to use this data in remote parcel requests.
meow-7.2.2
Seth ProductEngine 2010-12-30 18:18:33 +02:00
parent 964e981458
commit 376ee7a3f9
8 changed files with 174 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include "llcachename.h"
#include "lltrans.h"
#include "lluicolortable.h"
#include "message.h"
#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))"
@ -740,6 +741,13 @@ std::string LLUrlEntryObjectIM::getLocation(const std::string &url) const
return LLUrlEntryBase::getLocation(url);
}
// LLUrlEntryParcel statics.
LLUUID LLUrlEntryParcel::sAgentID(LLUUID::null);
LLUUID LLUrlEntryParcel::sSessionID(LLUUID::null);
LLHost LLUrlEntryParcel::sRegionHost(LLHost::invalid);
bool LLUrlEntryParcel::sDisconnected(false);
std::set<LLUrlEntryParcel*> LLUrlEntryParcel::sParcelInfoObservers;
///
/// LLUrlEntryParcel Describes a Second Life parcel Url, e.g.,
/// secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about
@ -751,13 +759,88 @@ LLUrlEntryParcel::LLUrlEntryParcel()
boost::regex::perl|boost::regex::icase);
mMenuName = "menu_url_parcel.xml";
mTooltip = LLTrans::getString("TooltipParcelUrl");
sParcelInfoObservers.insert(this);
}
LLUrlEntryParcel::~LLUrlEntryParcel()
{
sParcelInfoObservers.erase(this);
}
std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
LLSD path_array = LLURI(url).pathArray();
S32 path_parts = path_array.size();
if (path_parts < 3) // no parcel id
{
llwarns << "Failed to parse url [" << url << "]" << llendl;
return url;
}
std::string parcel_id_string = unescapeUrl(path_array[2]); // parcel id
// Add an observer to call LLUrlLabelCallback when we have parcel name.
addObserver(parcel_id_string, url, cb);
LLUUID parcel_id(parcel_id_string);
sendParcelInfoRequest(parcel_id);
return unescapeUrl(url);
}
void LLUrlEntryParcel::sendParcelInfoRequest(const LLUUID& parcel_id)
{
if (sRegionHost == LLHost::invalid || sDisconnected) return;
LLMessageSystem *msg = gMessageSystem;
msg->newMessage("ParcelInfoRequest");
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, sAgentID );
msg->addUUID("SessionID", sSessionID);
msg->nextBlock("Data");
msg->addUUID("ParcelID", parcel_id);
msg->sendReliable(sRegionHost);
}
void LLUrlEntryParcel::onParcelInfoReceived(const std::string &id, const std::string &label)
{
callObservers(id, label.empty() ? LLTrans::getString("RegionInfoError") : label, mIcon);
}
// static
void LLUrlEntryParcel::processParcelInfo(const LLParcelData& parcel_data)
{
std::string label(LLStringUtil::null);
if (!parcel_data.name.empty())
{
label = parcel_data.name;
}
// If parcel name is empty use Sim_name (x, y, z) for parcel label.
else if (!parcel_data.sim_name.empty())
{
S32 region_x = llround(parcel_data.global_x) % REGION_WIDTH_UNITS;
S32 region_y = llround(parcel_data.global_y) % REGION_WIDTH_UNITS;
S32 region_z = llround(parcel_data.global_z);
label = llformat("%s (%d, %d, %d)",
parcel_data.sim_name.c_str(), region_x, region_y, region_z);
}
for (std::set<LLUrlEntryParcel*>::iterator iter = sParcelInfoObservers.begin();
iter != sParcelInfoObservers.end();
++iter)
{
LLUrlEntryParcel* url_entry = *iter;
if (url_entry)
{
url_entry->onParcelInfoReceived(parcel_data.parcel_id.asString(), label);
}
}
}
//
// LLUrlEntryPlace Describes secondlife://<location> URLs
//

View File

@ -31,6 +31,9 @@
#include "lluuid.h"
#include "lluicolor.h"
#include "llstyle.h"
#include "llhost.h" // for resolving parcel name by parcel id
#include <boost/signals2.hpp>
#include <boost/regex.hpp>
#include <string>
@ -285,8 +288,44 @@ private:
class LLUrlEntryParcel : public LLUrlEntryBase
{
public:
struct LLParcelData
{
LLUUID parcel_id;
std::string name;
std::string sim_name;
F32 global_x;
F32 global_y;
F32 global_z;
};
LLUrlEntryParcel();
~LLUrlEntryParcel();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
// Sends a parcel info request to sim.
void sendParcelInfoRequest(const LLUUID& parcel_id);
// Calls observers of certain parcel id providing them with parcel label.
void onParcelInfoReceived(const std::string &id, const std::string &label);
// Processes parcel label and triggers notifying observers.
static void processParcelInfo(const LLParcelData& parcel_data);
// Next 4 setters are used to update agent and viewer connection information
// upon events like user login, viewer disconnect and user changing region host.
// These setters are made public to be accessible from newview and should not be
// used in other cases.
static void setAgentID(const LLUUID& id) { sAgentID = id; }
static void setSessionID(const LLUUID& id) { sSessionID = id; }
static void setRegionHost(const LLHost& host) { sRegionHost = host; }
static void setDisconnected(bool disconnected) { sDisconnected = disconnected; }
private:
static LLUUID sAgentID;
static LLUUID sSessionID;
static LLHost sRegionHost;
static bool sDisconnected;
static std::set<LLUrlEntryParcel*> sParcelInfoObservers;
};
///

View File

@ -30,6 +30,7 @@
#include "llavatarnamecache.h"
#include "llcachename.h"
#include "lluuid.h"
#include "message.h"
#include <string>
@ -191,3 +192,20 @@ LLFontGL* LLFontGL::getFontDefault()
{
return NULL;
}
char* _PREHASH_AgentData = "AgentData";
char* _PREHASH_AgentID = "AgentID";
LLHost LLHost::invalid(INVALID_PORT,INVALID_HOST_IP_ADDRESS);
LLMessageSystem* gMessageSystem = NULL;
//
// Stub implementation for LLMessageSystem
//
void LLMessageSystem::newMessage(const char *name) { }
void LLMessageSystem::nextBlockFast(const char *blockname) { }
void LLMessageSystem::nextBlock(const char *blockname) { }
void LLMessageSystem::addUUIDFast( const char *varname, const LLUUID& uuid) { }
void LLMessageSystem::addUUID( const char *varname, const LLUUID& uuid) { }
S32 LLMessageSystem::sendReliable(const LLHost &host) { return 0; }

View File

@ -64,6 +64,7 @@
#include "lltool.h"
#include "lltoolmgr.h"
#include "lltrans.h"
#include "llurlentry.h"
#include "llviewercontrol.h"
#include "llviewerdisplay.h"
#include "llviewerjoystick.h"
@ -649,6 +650,10 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
}
mRegionp = regionp;
// Pass the region host to LLUrlEntryParcel to resolve parcel name
// with a server request.
LLUrlEntryParcel::setRegionHost(getRegionHost());
// Must shift hole-covering water object locations because local
// coordinate frame changed.
LLWorld::getInstance()->updateWaterObjects();

View File

@ -93,6 +93,7 @@
#include "llmemory.h"
#include "llprimitive.h"
#include "llurlaction.h"
#include "llurlentry.h"
#include "llvfile.h"
#include "llvfsthread.h"
#include "llvolumemgr.h"
@ -4567,6 +4568,10 @@ void LLAppViewer::disconnectViewer()
cleanup_xfer_manager();
gDisconnected = TRUE;
// Pass the connection state to LLUrlEntryParcel not to attempt
// parcel info requests while disconnected.
LLUrlEntryParcel::setDisconnected(gDisconnected);
}
void LLAppViewer::forceErrorLLError()

View File

@ -33,6 +33,7 @@
#include "llpanel.h"
#include "llhttpclient.h"
#include "llsdserialize.h"
#include "llurlentry.h"
#include "llviewerregion.h"
#include "llview.h"
@ -168,6 +169,18 @@ void LLRemoteParcelInfoProcessor::processParcelInfoReply(LLMessageSystem* msg, v
{
observers.erase(*i);
}
LLUrlEntryParcel::LLParcelData url_data;
url_data.parcel_id = parcel_data.parcel_id;
url_data.name = parcel_data.name;
url_data.sim_name = parcel_data.sim_name;
url_data.global_x = parcel_data.global_x;
url_data.global_y = parcel_data.global_y;
url_data.global_z = parcel_data.global_z;
// Pass the parcel data to LLUrlEntryParcel to render
// human readable parcel name.
LLUrlEntryParcel::processParcelInfo(url_data);
}
void LLRemoteParcelInfoProcessor::sendParcelInfoRequest(const LLUUID& parcel_id)

View File

@ -139,6 +139,7 @@
#include "lltrans.h"
#include "llui.h"
#include "llurldispatcher.h"
#include "llurlentry.h"
#include "llslurl.h"
#include "llurlhistory.h"
#include "llurlwhitelist.h"
@ -2882,9 +2883,17 @@ bool process_login_success_response()
if(!text.empty()) gAgentID.set(text);
gDebugInfo["AgentID"] = text;
// Agent id needed for parcel info request in LLUrlEntryParcel
// to resolve parcel name.
LLUrlEntryParcel::setAgentID(gAgentID);
text = response["session_id"].asString();
if(!text.empty()) gAgentSessionID.set(text);
gDebugInfo["SessionID"] = text;
// Session id needed for parcel info request in LLUrlEntryParcel
// to resolve parcel name.
LLUrlEntryParcel::setSessionID(gAgentSessionID);
text = response["secure_session_id"].asString();
if(!text.empty()) gAgent.mSecureSessionID.set(text);

View File

@ -32,6 +32,7 @@
#include "../llagent.h"
#include "message.h"
#include "llurlentry.h"
namespace {
LLControlGroup s_saved_settings("dummy_settings");
@ -72,6 +73,7 @@ LLUIColor::LLUIColor(void) { }
LLAgentAccess::LLAgentAccess(LLControlGroup & settings) : mSavedSettings(settings) { }
LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker<LLControlGroup, std::string>(name) { }
LLControlGroup::~LLControlGroup(void) { }
void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { }
namespace tut
{