Skip to content
Snippets Groups Projects
Commit 37917450 authored by James Cook's avatar James Cook
Browse files

Simple button to change your display name

Talks to web service so other people can see the change, but for now
they need to relog or toggle display names on/off to clear their
cache.
parent d3582dc3
No related branches found
No related tags found
No related merge requests found
......@@ -241,6 +241,39 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, name_cache_callback_t callba
{
}
class LLSetNameResponder : public LLHTTPClient::Responder
{
public:
LLUUID mAgentID;
LLSetNameResponder(const LLUUID& agent_id) : mAgentID(agent_id) { }
/*virtual*/ void result(const LLSD& content)
{
// force re-fetch
LLAvatarNameCache::sCache.erase(mAgentID);
llinfos << "JAMESDEBUG set names worked" << llendl;
}
/*virtual*/ void error(U32 status, const std::string& reason)
{
llinfos << "JAMESDEBUG set names failed " << status
<< " reason " << reason << llendl;
}
};
void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string& display_name)
{
LLSD body;
body["display_name"] = display_name;
// *TODO: configure the base URL for this
std::string url = "http://pdp15.lindenlab.com:8050/my-service/agent/";
url += agent_id.asString();
url += "/set-display-name/";
LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id));
}
void LLAvatarNameCache::toggleDisplayNames()
{
sUseDisplayNames = !sUseDisplayNames;
......
......@@ -56,6 +56,9 @@ namespace LLAvatarNameCache
typedef void (*name_cache_callback_t)(const LLUUID& agent_id, const LLAvatarName& av_name);
void get(const LLUUID& agent_id, name_cache_callback_t callback);
// Sends an update to the server
void setDisplayName(const LLUUID& agent_id, const std::string& display_name);
// HACK: turn display names on and off
void toggleDisplayNames();
bool useDisplayNames();
......
......@@ -33,11 +33,14 @@
#include "llviewerprecompiledheaders.h"
#include "llpanelprofile.h"
#include "llavatarconstants.h"
#include "llavatarnamecache.h" // IDEVO
#include "llpanelme.h"
#include "llagent.h"
#include "llagentwearables.h"
#include "lliconctrl.h"
#include "llnotificationsutil.h" // IDEVO
#include "llsidetray.h"
#include "lltabcontainer.h"
#include "lltexturectrl.h"
......@@ -228,6 +231,21 @@ void LLPanelMyProfileEdit::processProfileProperties(const LLAvatarData* avatar_d
//{
// childSetTextArg("name_text", "[NAME]", full_name);
//}
std::string full_name;
LLAvatarName av_name;
if (LLAvatarNameCache::useDisplayNames()
&& LLAvatarNameCache::get(avatar_data->avatar_id, &av_name))
{
getChild<LLUICtrl>("user_name")->setValue( av_name.mDisplayName );
getChild<LLUICtrl>("user_slid")->setValue( av_name.mSLID );
}
else if (gCacheName->getFullName(avatar_data->avatar_id, full_name))
{
getChild<LLUICtrl>("user_name")->setValue(full_name);
getChild<LLUICtrl>("user_slid")->setValue("");
}
getChild<LLUICtrl>("set_name")->setVisible( LLAvatarNameCache::useDisplayNames() );
}
BOOL LLPanelMyProfileEdit::postBuild()
......@@ -237,6 +255,9 @@ BOOL LLPanelMyProfileEdit::postBuild()
childSetTextArg("partner_edit_link", "[URL]", getString("partner_edit_link_url"));
childSetTextArg("my_account_link", "[URL]", getString("my_account_link_url"));
getChild<LLUICtrl>("set_name")->setCommitCallback(
boost::bind(&LLPanelMyProfileEdit::onClickSetName, this));
return LLPanelAvatarProfile::postBuild();
}
/**
......@@ -277,6 +298,45 @@ void LLPanelMyProfileEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl)
mTextureEditIconMap[ctrl->getName()]->setVisible(FALSE);
}
static void set_name_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (option == 0)
{
LLUUID agent_id = notification["payload"]["agent_id"];
if (agent_id.isNull()) return;
std::string display_name = response["display_name"].asString();
LLAvatarNameCache::setDisplayName(agent_id, display_name);
}
}
void LLPanelMyProfileEdit::onClickSetName()
{
// IDEVO
LLUUID agent_id = getAvatarId();
std::string display_name;
LLAvatarName av_name;
if (LLAvatarNameCache::useDisplayNames()
&& LLAvatarNameCache::get(agent_id, &av_name))
{
display_name = av_name.mDisplayName;
}
else
{
gCacheName->getFullName(agent_id, display_name);
}
if (!display_name.empty())
{
LLSD args;
args["DISPLAY_NAME"] = display_name;
LLSD payload;
payload["agent_id"] = agent_id;
LLNotificationsUtil::add("SetDisplayName", args, payload, set_name_callback);
}
}
void LLPanelMyProfileEdit::enableEditing(bool enable)
{
childSetEnabled("2nd_life_pic", enable);
......
......@@ -95,6 +95,7 @@ class LLPanelMyProfileEdit : public LLPanelMyProfile
void initTexturePickerMouseEvents();
void onTexturePickerMouseEnter(LLUICtrl* ctrl);
void onTexturePickerMouseLeave(LLUICtrl* ctrl);
void onClickSetName();
/**
* Enabled/disables controls to prevent overwriting edited data upon receiving
......
......@@ -3030,6 +3030,27 @@ You are no longer frozen.
</form>
</notification>
<notification
icon="alertmodal.tga"
name="SetDisplayName"
type="alertmodal">
Change your display name?
<form name="form">
<input name="display_name" type="text">
[DISPLAY_NAME]
</input>
<button
default="true"
index="0"
name="Change"
text="Change"/>
<button
index="1"
name="Cancel"
text="Cancel"/>
</form>
</notification>
<notification
icon="alertmodal.tga"
name="OfferTeleport"
......
......@@ -87,12 +87,42 @@
min_height="300"
left="0"
width="290">
<panel
<text
follows="top|left"
font="SansSerifHuge"
height="13"
layout="topleft"
left="10"
name="user_name"
text_color="LtGray"
top="0"
value="James Linden"
width="150" />
<button
follows="top|left"
height="23"
label="Set Name..."
left="170"
name="set_name"
top="0"
visible="false"
width="110" />
<text
follows="top|left"
height="13"
layout="topleft"
left="10"
name="user_slid"
text_color="LtGray"
top_pad="4"
value="(james.linden)"
width="150" />
<panel
name="lifes_images_panel"
follows="left|top|right"
height="244"
layout="topleft"
top="0"
top="37"
left="0"
width="290">
<panel
......@@ -145,7 +175,7 @@
height="102"
layout="topleft"
left="123"
top="25"
top="62"
max_length="512"
name="sl_description_edit"
width="157"
......@@ -201,7 +231,7 @@
layout="topleft"
left="123"
max_length="512"
top="157"
top="195"
name="fl_description_edit"
width="157"
word_wrap="true">
......
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