diff options
author | James Cook <james@lindenlab.com> | 2010-03-18 17:19:57 -0700 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2010-03-18 17:19:57 -0700 |
commit | 639b234762133e4d09d6d7b1bac9d25c5a681926 (patch) | |
tree | d99a727f3fa9c53faecd434b2735da1094b9a519 | |
parent | 10fc6ee4a012fa7232868261d6e11a76652c3cca (diff) |
Partial support for Set Name returning error msg from service
-rw-r--r-- | indra/llmessage/llavatarnamecache.cpp | 20 | ||||
-rw-r--r-- | indra/llmessage/llavatarnamecache.h | 18 | ||||
-rw-r--r-- | indra/newview/llpanelme.cpp | 57 | ||||
-rw-r--r-- | indra/newview/llpanelme.h | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 21 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_edit_profile.xml | 1 |
6 files changed, 92 insertions, 30 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d7284c41a7..d49f1d3de5 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -37,6 +37,7 @@ #include "llcachename.h" // *TODO: remove #include "llframetimer.h" #include "llhttpclient.h" +#include "llsd.h" #include <map> #include <set> @@ -266,23 +267,36 @@ class LLSetNameResponder : public LLHTTPClient::Responder { public: LLUUID mAgentID; + LLAvatarNameCache::set_name_signal_t mSignal; - LLSetNameResponder(const LLUUID& agent_id) : mAgentID(agent_id) { } + 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 << "JAMESDEBUG set names failed " << status << " reason " << reason << llendl; + + mSignal(false, reason, LLSD()); } }; -void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string& display_name) +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; @@ -291,7 +305,7 @@ void LLAvatarNameCache::setDisplayName(const LLUUID& agent_id, const std::string std::string url = sNameServiceBaseURL + "agent/"; url += agent_id.asString(); url += "/set-display-name/"; - LLHTTPClient::post(url, body, new LLSetNameResponder(agent_id)); + 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 a09f549877..8fc43860da 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -37,6 +37,9 @@ #include <boost/signals2.hpp> +class LLSD; +class LLUUID; + namespace LLAvatarNameCache { void initClass(); @@ -53,6 +56,7 @@ namespace LLAvatarNameCache // otherwise returns false bool get(const LLUUID& agent_id, LLAvatarName *av_name); + // Callback types for get() below typedef boost::signals2::signal< void (const LLUUID& agent_id, const LLAvatarName& av_name)> callback_signal_t; @@ -61,9 +65,17 @@ namespace LLAvatarNameCache // Fetches name information and calls callback. // If name information is in cache, callback will be called immediately. void get(const LLUUID& agent_id, callback_slot_t slot); - - // Sends an update to the server - void setDisplayName(const LLUUID& agent_id, const std::string& display_name); + + // 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(); diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp index 84ed7356f1..d6c7d7ea8d 100644 --- a/indra/newview/llpanelme.cpp +++ b/indra/newview/llpanelme.cpp @@ -235,21 +235,14 @@ 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(""); - } + LLAvatarNameCache::get(avatar_data->avatar_id, + boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); +} - getChild<LLUICtrl>("set_name")->setVisible( LLAvatarNameCache::useDisplayNames() ); +void LLPanelMyProfileEdit::onNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) +{ + getChild<LLUICtrl>("user_name")->setValue( av_name.mDisplayName ); + getChild<LLUICtrl>("user_slid")->setValue( av_name.mSLID ); } BOOL LLPanelMyProfileEdit::postBuild() @@ -307,7 +300,30 @@ void LLPanelMyProfileEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl) // IDEVO HACK extern void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel); -void LLPanelMyProfileEdit::callbackSetName(const LLSD& notification, const LLSD& response) +void LLPanelMyProfileEdit::onCacheSetName(bool success, + const std::string& reason, + const LLSD& content) +{ + if (success) + { + // HACK: Use chat to invalidate names + send_chat_from_viewer("refreshname", CHAT_TYPE_NORMAL, 0); + + // Re-fetch my name, as it may have been sanitized by the service + LLAvatarNameCache::get(getAvatarId(), + boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); + } + else + { + // JAMESDEBUG TODO: localize strings for reasons we couldn't + // change the name + LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); + // TODO: SetDisplayNameFailedThrottle with [FREQUENCY] + // TODO: SetDisplayNameFailedUnavailable + } +} + +void LLPanelMyProfileEdit::onDialogSetName(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (option == 0) @@ -316,12 +332,9 @@ void LLPanelMyProfileEdit::callbackSetName(const LLSD& notification, const LLSD& if (agent_id.isNull()) return; std::string display_name = response["display_name"].asString(); - LLAvatarNameCache::setDisplayName(agent_id, display_name); - - // HACK: Use chat to invalidate names - send_chat_from_viewer("refreshname", CHAT_TYPE_NORMAL, 0); - - getChild<LLUICtrl>("user_name")->setValue( display_name ); + LLAvatarNameCache::setDisplayName(agent_id, display_name, + boost::bind(&LLPanelMyProfileEdit::onCacheSetName, this, + _1, _2, _3)); } } @@ -348,7 +361,7 @@ void LLPanelMyProfileEdit::onClickSetName() LLSD payload; payload["agent_id"] = agent_id; LLNotificationsUtil::add("SetDisplayName", args, payload, - boost::bind(&LLPanelMyProfileEdit::callbackSetName, this, _1, _2)); + boost::bind(&LLPanelMyProfileEdit::onDialogSetName, this, _1, _2)); } } diff --git a/indra/newview/llpanelme.h b/indra/newview/llpanelme.h index ed630133ca..9304bc1d82 100644 --- a/indra/newview/llpanelme.h +++ b/indra/newview/llpanelme.h @@ -36,6 +36,7 @@ #include "llpanel.h" #include "llpanelprofile.h" +class LLAvatarName; class LLPanelMyProfileEdit; class LLPanelProfile; class LLIconCtrl; @@ -90,13 +91,15 @@ protected: /*virtual*/void resetData(); void processProfileProperties(const LLAvatarData* avatar_data); + void onNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); private: void initTexturePickerMouseEvents(); void onTexturePickerMouseEnter(LLUICtrl* ctrl); void onTexturePickerMouseLeave(LLUICtrl* ctrl); void onClickSetName(); - void callbackSetName(const LLSD& notification, const LLSD& response); + void onDialogSetName(const LLSD& notification, const LLSD& response); + void onCacheSetName(bool success, const std::string& reason, const LLSD& content); /** * Enabled/disables controls to prevent overwriting edited data upon receiving diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 8c07198111..e7d64fd82f 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3055,6 +3055,27 @@ Change your display name? <notification icon="alertmodal.tga" + name="SetDisplayNameFailedGeneric" + type="alertmodal"> + Sorry, we could not set your display name. Please try again later. + </notification> + + <notification + icon="alertmodal.tga" + name="SetDisplayNameFailedThrottle" + type="alertmodal"> + Sorry, you can only change your display name once every [FREQUENCY] hour(s). + </notification> + + <notification + icon="alertmodal.tga" + name="SetDisplayNameFailedUnavailable" + type="alertmodal"> + Sorry, we could not set that display name. Please try a different name. + </notification> + + <notification + icon="alertmodal.tga" name="OfferTeleport" type="alertmodal"> Offer a teleport to your location with the following message? diff --git a/indra/newview/skins/default/xui/en/panel_edit_profile.xml b/indra/newview/skins/default/xui/en/panel_edit_profile.xml index 1b624da68a..bce988da9d 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_profile.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_profile.xml @@ -115,7 +115,6 @@ left="170" name="set_name" top_delta="-4" - visible="false" width="110" /> <panel name="lifes_images_panel" |