diff --git a/indra/llmessage/aihttptimeoutpolicy.cpp b/indra/llmessage/aihttptimeoutpolicy.cpp index 96bf6e10a..49d230b88 100644 --- a/indra/llmessage/aihttptimeoutpolicy.cpp +++ b/indra/llmessage/aihttptimeoutpolicy.cpp @@ -907,7 +907,6 @@ AIHTTPTimeoutPolicy const* AIHTTPTimeoutPolicy::getTimeoutPolicyByName(std::stri // Policy name Policy P(assetReportHandler); P(authHandler); -P(avatarNameResponder); P2(baseCapabilitiesComplete, transfer_18s_connect_5s); P(blockingLLSDPost); P(blockingLLSDGet); @@ -926,8 +925,6 @@ P(fetchScriptLimitsRegionSummaryResponder); P(fnPtrResponder); P(floaterPermsResponder); P2(gamingDataReceived, transfer_22s_connect_10s); -P(groupBanDataResponder); -P2(groupMemberDataResponder, transfer_300s); P2(groupProposalBallotResponder, transfer_300s); P(homeLocationResponder); P2(HTTPGetResponder, reply_15s); @@ -962,14 +959,11 @@ P(startConferenceChatResponder); P2(startGroupVoteResponder, transfer_300s); P(translationReceiver); P(uploadModelPremissionsResponder); -P(userReportResponder); P(verifiedDestinationResponder); P(viewerChatterBoxInvitationAcceptResponder); P(viewerMediaOpenIDResponder); P(viewerMediaWebProfileResponder); P(viewerStatsResponder); -P(vivoxVoiceAccountProvisionResponder); -P(vivoxVoiceClientCapResponder); P(voiceCallCapResponder); P(webProfileResponders); P(wholeModelFeeResponder); diff --git a/indra/llmessage/llavatarname.cpp b/indra/llmessage/llavatarname.cpp index c05ac09d5..b50c643b1 100644 --- a/indra/llmessage/llavatarname.cpp +++ b/indra/llmessage/llavatarname.cpp @@ -30,6 +30,7 @@ #include "llavatarname.h" #include "lldate.h" +#include "llframetimer.h" #include "llsd.h" // Store these in pre-built std::strings to avoid memory allocations in @@ -42,6 +43,15 @@ static const std::string IS_DISPLAY_NAME_DEFAULT("is_display_name_default"); static const std::string DISPLAY_NAME_EXPIRES("display_name_expires"); static const std::string DISPLAY_NAME_NEXT_UPDATE("display_name_next_update"); +bool LLAvatarName::sUseDisplayNames = true; +bool LLAvatarName::sUseUsernames = true; + +// Minimum time-to-live (in seconds) for a name entry. +// Avatar name should always guarantee to expire reasonably soon by default +// so if the failure to get a valid expiration time was due to something temporary +// we will eventually request and get the right data. +const F64 MIN_ENTRY_LIFETIME = 60.0; + LLAvatarName::LLAvatarName() : mUsername(), mDisplayName(), @@ -61,6 +71,27 @@ bool LLAvatarName::operator<(const LLAvatarName& rhs) const return mUsername < rhs.mUsername; } +//static +void LLAvatarName::setUseDisplayNames(bool use) +{ + sUseDisplayNames = use; +} +//static +bool LLAvatarName::useDisplayNames() +{ + return sUseDisplayNames; +} + +void LLAvatarName::setUseUsernames(bool use) +{ + sUseUsernames = use; +} + +bool LLAvatarName::useUsernames() +{ + return sUseUsernames; +} + LLSD LLAvatarName::asLLSD() const { LLSD sd; @@ -85,27 +116,90 @@ void LLAvatarName::fromLLSD(const LLSD& sd) mExpires = expires.secondsSinceEpoch(); LLDate next_update = sd[DISPLAY_NAME_NEXT_UPDATE]; mNextUpdate = next_update.secondsSinceEpoch(); + + // Some avatars don't have explicit display names set. Force a legible display name here. + if (mDisplayName.empty()) + { + mDisplayName = mUsername; + } +} + +// Transform a string (typically provided by the legacy service) into a decent +// avatar name instance. +void LLAvatarName::fromString(const std::string& full_name) +{ + mDisplayName = full_name; + std::string::size_type index = full_name.find(' '); + if (index != std::string::npos) + { + // The name is in 2 parts (first last) + mLegacyFirstName = full_name.substr(0, index); + mLegacyLastName = full_name.substr(index+1); + if (mLegacyLastName != "Resident") + { + mUsername = mLegacyFirstName + "." + mLegacyLastName; + mDisplayName = full_name; + LLStringUtil::toLower(mUsername); + } + else + { + // Very old names do have a dummy "Resident" last name + // that we choose to hide from users. + mUsername = mLegacyFirstName; + mDisplayName = mLegacyFirstName; + } + } + else + { + mLegacyFirstName = full_name; + mLegacyLastName = ""; + mUsername = full_name; + mDisplayName = full_name; + } + mIsDisplayNameDefault = true; + mIsTemporaryName = true; + setExpires(MIN_ENTRY_LIFETIME); +} + +void LLAvatarName::setExpires(F64 expires) +{ + mExpires = LLFrameTimer::getTotalSeconds() + expires; } std::string LLAvatarName::getCompleteName(bool linefeed) const { std::string name; - if (mUsername.empty() || mIsDisplayNameDefault) - // If the display name feature is off - // OR this particular display name is defaulted (i.e. based on user name), - // then display only the easier to read instance of the person's name. + if (sUseDisplayNames) { - name = mDisplayName; + if (mUsername.empty() || mIsDisplayNameDefault) + { + // If this particular display name is defaulted (i.e. based on user name), + // then display only the easier to read instance of the person's name. + name = mDisplayName; + } + else + { + name = mDisplayName; + if (sUseUsernames) + { + name += (linefeed ? "\n(" : " (") + mUsername + ")"; + } + } } else { - name = mDisplayName + (linefeed ? "\n(" : " (") + mUsername + ")"; + name = getUserName(); } return name; } std::string LLAvatarName::getLegacyName() const { + if (mLegacyFirstName.empty() && mLegacyLastName.empty()) // display names disabled? + { + return mDisplayName; + } + std::string name; name.reserve( mLegacyFirstName.size() + 1 + mLegacyLastName.size() ); name = mLegacyFirstName; @@ -113,3 +207,48 @@ std::string LLAvatarName::getLegacyName() const name += mLegacyLastName; return name; } + +std::string LLAvatarName::getDisplayName() const +{ + if (sUseDisplayNames) + { + return mDisplayName; + } + else + { + return getUserName(); + } +} + +std::string LLAvatarName::getUserName() const +{ + std::string name; + if (mLegacyLastName.empty() /*|| (mLegacyLastName == "Resident")*/) // + { + if (mLegacyFirstName.empty()) + { + // If we cannot create a user name from the legacy strings, use the display name + name = mDisplayName; + } + else + { + // The last name might be empty if it defaulted to "Resident" + name = mLegacyFirstName; + } + } + else + { + name = mLegacyFirstName + " " + mLegacyLastName; + } + return name; +} + +void LLAvatarName::dump() const +{ + LL_DEBUGS("AvNameCache") << "LLAvatarName: " + << "user '" << mUsername << "' " + << "display '" << mDisplayName << "' " + << "expires in " << mExpires - LLFrameTimer::getTotalSeconds() << " seconds" + << LL_ENDL; +} + diff --git a/indra/llmessage/llavatarname.h b/indra/llmessage/llavatarname.h index 998d23c42..5902d34d8 100644 --- a/indra/llmessage/llavatarname.h +++ b/indra/llmessage/llavatarname.h @@ -30,6 +30,8 @@ #include +const S32& main_name_system(); + class LLSD; class LLAvatarName @@ -39,10 +41,30 @@ public: bool operator<(const LLAvatarName& rhs) const; + // Conversion to and from LLSD (cache file or server response) LLSD asLLSD() const; - void fromLLSD(const LLSD& sd); + // Used only in legacy mode when the display name capability is not provided server side + // or to otherwise create a temporary valid item. + void fromString(const std::string& full_name); + + // Set the name object to become invalid in "expires" seconds from now + void setExpires(F64 expires); + + // Set and get the display name flag set by the user in preferences. + static void setUseDisplayNames(bool use); + static bool useDisplayNames(); + + static void setUseUsernames(bool use); + static bool useUsernames(); + + // A name object is valid if not temporary and not yet expired (default is expiration not checked) + bool isValidName(F64 max_unrefreshed = 0.0f) const { return !mIsTemporaryName && (mExpires >= max_unrefreshed); } + + // Return true if the name is made up from legacy or temporary data + bool isDisplayNameDefault() const { return mIsDisplayNameDefault; } + // For normal names, returns "James Linden (james.linden)" // When display names are disabled returns just "James Linden" std::string getCompleteName(bool linefeed = false) const; @@ -52,10 +74,49 @@ public: // *TODO: Eliminate this in favor of username only std::string getLegacyName() const; + // "José Sanchez" or "James Linden", UTF-8 encoded Unicode + // Takes the display name preference into account. This is truly the name that should + // be used for all UI where an avatar name has to be used unless we truly want something else (rare) + std::string getDisplayName() const; + + // Returns "James Linden" or "bobsmith123 Resident" + // Used where we explicitely prefer or need a non UTF-8 legacy (ASCII) name + // Also used for backwards compatibility with systems like voice and muting + std::string getUserName() const; + + // Returns "james.linden" or the legacy name for very old names + std::string getAccountName() const { return mUsername; } + + // Returns name in the format desired according to name_system + std::string getNSName(const S32& name_system = main_name_system()) const + { + switch (name_system) + { + case 1 : return getCompleteName(); + case 2 : return getDisplayName(); + case 3 : return getLegacyName() + (mIsDisplayNameDefault ? "" : " (" + mDisplayName + ")"); break; + default : return getLegacyName(); + } + } + + // Debug print of the object + void dump() const; + + // Names can change, so need to keep track of when name was + // last checked. + // Unix time-from-epoch seconds for efficiency + F64 mExpires; + + // You can only change your name every N hours, so record + // when the next update is allowed + // Unix time-from-epoch seconds + F64 mNextUpdate; + +private: // "bobsmith123" or "james.linden", US-ASCII only std::string mUsername; - // "Jose' Sanchez" or "James Linden", UTF-8 encoded Unicode + // "José Sanchez" or "James Linden", UTF-8 encoded Unicode // Contains data whether or not user has explicitly set // a display name; may duplicate their username. std::string mDisplayName; @@ -81,15 +142,12 @@ public: // shown in UI, but are not serialized. bool mIsTemporaryName; - // Names can change, so need to keep track of when name was - // last checked. - // Unix time-from-epoch seconds for efficiency - F64 mExpires; - - // You can only change your name every N hours, so record - // when the next update is allowed - // Unix time-from-epoch seconds - F64 mNextUpdate; + // Global flag indicating if display name should be used or not + // This will affect the output of the high level "get" methods + static bool sUseDisplayNames; + + // Flag indicating if username should be shown after display name or not + static bool sUseUsernames; }; #endif diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index d6aca358e..61d5ee63e 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -44,10 +44,6 @@ namespace LLAvatarNameCache { use_display_name_signal_t mUseDisplayNamesSignal; - // Manual override for display names - can disable even if the region - // supports it. - bool sUseDisplayNames = true; - // [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c // RLVa override for display names bool sForceDisplayNames = false; @@ -57,18 +53,22 @@ namespace LLAvatarNameCache // current region supports display names. bool sRunning = false; + // Use the People API (modern) for fetching name if true. Use the old legacy protocol if false. + // For testing, there's a UsePeopleAPI setting that can be flipped (must restart viewer). + bool sUsePeopleAPI = true; + // Base lookup URL for name service. // On simulator, loaded from indra.xml // 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 + // Accumulated agent IDs for next query against service typedef std::set ask_queue_t; ask_queue_t sAskQueue; - // agent IDs that have been requested, but with no reply - // maps agent ID to frame time request was made + // Agent IDs that have been requested, but with no reply. + // Maps agent ID to frame time request was made. typedef std::map pending_queue_t; pending_queue_t sPendingQueue; @@ -79,21 +79,21 @@ namespace LLAvatarNameCache typedef std::map signal_map_t; signal_map_t sSignalMap; - // names we know about + // The cache at last, i.e. avatar names we know about. typedef std::map cache_t; cache_t sCache; - // Send bulk lookup requests a few times a second at most - // only need per-frame timing resolution + // Send bulk lookup requests a few times a second at most. + // Only need per-frame timing resolution. LLFrameTimer sRequestTimer; - /// Maximum time an unrefreshed cache entry is allowed + // Maximum time an unrefreshed cache entry is allowed. const F64 MAX_UNREFRESHED_TIME = 20.0 * 60.0; - /// Time when unrefreshed cached names were checked last + // Time when unrefreshed cached names were checked last. static F64 sLastExpireCheck; - /// Time-to-live for a temp cache entry. + // Time-to-live for a temp cache entry. const F64 TEMP_CACHE_ENTRY_LIFETIME = 60.0; //----------------------------------------------------------------------- @@ -101,26 +101,21 @@ namespace LLAvatarNameCache //----------------------------------------------------------------------- // Handle name response off network. - // Optionally skip adding to cache, used when this is a fallback to the - // legacy name system. void processName(const LLUUID& agent_id, - const LLAvatarName& av_name, - bool add_to_cache); + const LLAvatarName& av_name); void requestNamesViaCapability(); - // Legacy name system callback + // Legacy name system callbacks void legacyNameCallback(const LLUUID& agent_id, const std::string& full_name, - bool is_group - ); + bool is_group); + void legacyNameFetch(const LLUUID& agent_id, + const std::string& full_name, + bool is_group); void requestNamesViaLegacy(); - // Fill in an LLAvatarName with the legacy name data - void buildLegacyName(const std::string& full_name, - LLAvatarName* av_name); - // Do a single callback to a given slot void fireSignal(const LLUUID& agent_id, const callback_slot_t& slot, @@ -174,31 +169,37 @@ namespace LLAvatarNameCache */ -class AIHTTPTimeoutPolicy; -extern AIHTTPTimeoutPolicy avatarNameResponder_timeout; - class LLAvatarNameResponder : public LLHTTPClient::ResponderWithResult { + LOG_CLASS(LLAvatarNameResponder); private: // need to store agent ids that are part of this request in case of // an error, so we can flag them as unavailable std::vector mAgentIDs; // Need the headers to look up Expires: and Retry-After: - virtual bool needsHeaders(void) const { return true; } - + /*virtual*/ bool needsHeaders() const { return true; } + /*virtual*/ char const* getName() const { return "LLAvatarNameResponder"; } + public: LLAvatarNameResponder(const std::vector& agent_ids) : mAgentIDs(agent_ids) { } - /*virtual*/ void httpSuccess(void) +protected: + /*virtual*/ void httpSuccess() { + const LLSD& content = getContent(); + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } // Pull expiration out of headers if available - F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mReceivedHeaders); + F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(getResponseHeaders()); F64 now = LLFrameTimer::getTotalSeconds(); - LLSD agents = mContent["agents"]; + const LLSD& agents = content["agents"]; LLSD::array_const_iterator it = agents.beginArray(); for ( ; it != agents.endArray(); ++it) { @@ -211,24 +212,15 @@ public: // Use expiration time from header av_name.mExpires = expires; - // Some avatars don't have explicit display names set - if (av_name.mDisplayName.empty()) - { - av_name.mDisplayName = av_name.mUsername; - } - - LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << " " - << "user '" << av_name.mUsername << "' " - << "display '" << av_name.mDisplayName << "' " - << "expires in " << expires - now << " seconds" - << LL_ENDL; + LL_DEBUGS("AvNameCache") << "LLAvatarNameResponder::result for " << agent_id << LL_ENDL; + av_name.dump(); // cache it and fire signals - LLAvatarNameCache::processName(agent_id, av_name, true); + LLAvatarNameCache::processName(agent_id, av_name); } // Same logic as error response case - LLSD unresolved_agents = mContent["bad_ids"]; + const LLSD& unresolved_agents = content["bad_ids"]; S32 num_unresolved = unresolved_agents.size(); if (num_unresolved > 0) { @@ -252,14 +244,13 @@ public: << LL_ENDL; } - /*virtual*/ void httpFailure(void) + /*virtual*/ void httpFailure() { // If there's an error, it might be caused by PeopleApi, // or when loading textures on startup and using a very slow // network, this query may time out. // What we should do depends on whether or not we have a cached name - LL_WARNS("AvNameCache") << "LLAvatarNameResponder::httpFailure " << mStatus << " " << mReason - << LL_ENDL; + LL_WARNS("AvNameCache") << dumpResponse() << LL_ENDL; // Add dummy records for any agent IDs in this request that we do not have cached already std::vector::const_iterator it = mAgentIDs.begin(); @@ -269,9 +260,6 @@ public: LLAvatarNameCache::handleAgentError(agent_id); } } - - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return avatarNameResponder_timeout; } - /*virtual*/ char const* getName(void) const { return "LLAvatarNameResponder"; } }; // Provide some fallback for agents that return errors @@ -284,48 +272,34 @@ void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id) LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent " << agent_id << LL_ENDL; gCacheName->get(agent_id, false, // legacy compatibility - boost::bind(&LLAvatarNameCache::legacyNameCallback, - _1, _2, _3)); + boost::bind(&LLAvatarNameCache::legacyNameFetch, _1, _2, _3)); } else { - // we have a chached (but probably expired) entry - since that would have + // we have a cached (but probably expired) entry - since that would have // been returned by the get method, there is no need to signal anyone // Clear this agent from the pending list LLAvatarNameCache::sPendingQueue.erase(agent_id); LLAvatarName& av_name = existing->second; - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent " - << agent_id - << "user '" << av_name.mUsername << "' " - << "display '" << av_name.mDisplayName << "' " - << "expires in " << av_name.mExpires - LLFrameTimer::getTotalSeconds() << " seconds" - << LL_ENDL; - av_name.mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME; // reset expiry time so we don't constantly rerequest. + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent " << agent_id << LL_ENDL; + av_name.dump(); + + // Reset expiry time so we don't constantly rerequest. + av_name.setExpires(TEMP_CACHE_ENTRY_LIFETIME); } } -void LLAvatarNameCache::processName(const LLUUID& agent_id, - const LLAvatarName& av_name, - bool add_to_cache) +void LLAvatarNameCache::processName(const LLUUID& agent_id, const LLAvatarName& av_name) { - if (add_to_cache) - { - // sCache[agent_id] = av_name; - // [SL:KB] - Patch: Agent-DisplayNames | Checked: 2010-12-28 (Catznip-2.4.0h) | Added: Catznip-2.4.0h - // Don't replace existing entries with dummies - cache_t::iterator itName = (av_name.mIsTemporaryName) ? sCache.find(agent_id) : sCache.end(); - if (sCache.end() != itName) - itName->second.mExpires = av_name.mExpires; - else - sCache[agent_id] = av_name; - // [/SL:KB] - } + // Add to the cache + sCache[agent_id] = av_name; + // Suppress request from the queue sPendingQueue.erase(agent_id); - // signal everyone waiting on this name + // Signal everyone waiting on this name signal_map_t::iterator sig_it = sSignalMap.find(agent_id); if (sig_it != sSignalMap.end()) { @@ -356,7 +330,6 @@ void LLAvatarNameCache::requestNamesViaCapability() std::vector agent_ids; agent_ids.reserve(128); - U32 id_total = sAskQueue.size(); U32 ids = 0; ask_queue_t::const_iterator it; while(!sAskQueue.empty()) @@ -393,7 +366,7 @@ void LLAvatarNameCache::requestNamesViaCapability() if (!url.empty()) { LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability requested " - << ids << "/" << id_total << "ids " + << ids << " ids" << LL_ENDL; LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); } @@ -403,22 +376,33 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id, const std::string& full_name, bool is_group) { - // Construct a dummy record for this name. By convention, SLID is blank - // Never expires, but not written to disk, so lasts until end of session. - LLAvatarName av_name; - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::legacyNameCallback " + // Put the received data in the cache + legacyNameFetch(agent_id, full_name, is_group); + + // Retrieve the name and set it to never (or almost never...) expire: when we are using the legacy + // protocol, we do not get an expiration date for each name and there's no reason to ask the + // data again and again so we set the expiration time to the largest value admissible. + std::map::iterator av_record = sCache.find(agent_id); + LLAvatarName& av_name = av_record->second; + av_name.setExpires(MAX_UNREFRESHED_TIME); +} + +void LLAvatarNameCache::legacyNameFetch(const LLUUID& agent_id, + const std::string& full_name, + bool is_group) +{ + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::legacyNameFetch " << "agent " << agent_id << " " << "full name '" << full_name << "'" << ( is_group ? " [group]" : "" ) << LL_ENDL; - buildLegacyName(full_name, &av_name); - // Add to cache, because if we don't we'll keep rerequesting the - // same record forever. buildLegacyName should always guarantee - // that these records expire reasonably soon - // (in TEMP_CACHE_ENTRY_LIFETIME seconds), so if the failure was due - // to something temporary we will eventually request and get the right data. - processName(agent_id, av_name, true); + // Construct an av_name record from this name. + LLAvatarName av_name; + av_name.fromString(full_name); + + // Add to cache: we're still using the new cache even if we're using the old (legacy) protocol. + processName(agent_id, av_name); } void LLAvatarNameCache::requestNamesViaLegacy() @@ -440,25 +424,28 @@ void LLAvatarNameCache::requestNamesViaLegacy() LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaLegacy agent " << agent_id << LL_ENDL; gCacheName->get(agent_id, false, // legacy compatibility - boost::bind(&LLAvatarNameCache::legacyNameCallback, - _1, _2, _3)); + boost::bind(&LLAvatarNameCache::legacyNameCallback, _1, _2, _3)); } } -void LLAvatarNameCache::initClass(bool running) +void LLAvatarNameCache::initClass(bool running, bool usePeopleAPI) { sRunning = running; + sUsePeopleAPI = usePeopleAPI; } void LLAvatarNameCache::cleanupClass() { + sCache.clear(); } void LLAvatarNameCache::importFile(std::istream& istr) { LLSD data; - S32 parse_count = LLSDSerialize::fromXMLDocument(data, istr); - if (parse_count < 1) return; + if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(data, istr)) + { + return; + } // by convention LLSD storage is a map // we only store one entry in the map @@ -490,7 +477,7 @@ void LLAvatarNameCache::exportFile(std::ostream& ostr) const LLUUID& agent_id = it->first; const LLAvatarName& av_name = it->second; // Do not write temporary or expired entries to the stored cache - if (!av_name.mIsTemporaryName && av_name.mExpires >= max_unrefreshed) + if (av_name.isValidName(max_unrefreshed)) { // key must be a string agents[agent_id.asString()] = av_name.asLLSD(); @@ -511,6 +498,11 @@ bool LLAvatarNameCache::hasNameLookupURL() return !sNameLookupURL.empty(); } +bool LLAvatarNameCache::usePeopleAPI() +{ + return hasNameLookupURL() && sUsePeopleAPI; +} + void LLAvatarNameCache::idle() { // By convention, start running at first idle() call @@ -527,13 +519,12 @@ void LLAvatarNameCache::idle() if (!sAskQueue.empty()) { - if (useDisplayNames()) + if (usePeopleAPI()) { requestNamesViaCapability(); } else { - // ...fall back to legacy name cache system requestNamesViaLegacy(); } } @@ -541,7 +532,7 @@ void LLAvatarNameCache::idle() if (sAskQueue.empty()) { // cleared the list, reset the request timer. - sRequestTimer.reset(SECS_BETWEEN_REQUESTS); + sRequestTimer.resetWithExpiry(SECS_BETWEEN_REQUESTS); } // erase anything that has not been refreshed for more than MAX_UNREFRESHED_TIME @@ -577,9 +568,8 @@ void LLAvatarNameCache::eraseUnrefreshed() const LLAvatarName& av_name = it->second; if (av_name.mExpires < max_unrefreshed) { - const LLUUID& agent_id = it->first; - LL_DEBUGS("AvNameCache") << agent_id - << " user '" << av_name.mUsername << "' " + LL_DEBUGS("AvNameCache") << it->first + << " user '" << av_name.getAccountName() << "' " << "expired " << now - av_name.mExpires << " secs ago" << LL_ENDL; sCache.erase(it++); @@ -593,29 +583,6 @@ void LLAvatarNameCache::eraseUnrefreshed() } } -void LLAvatarNameCache::buildLegacyName(const std::string& full_name, - LLAvatarName* av_name) -{ - llassert(av_name); - av_name->mUsername = ""; - av_name->mDisplayName = full_name; - av_name->mIsDisplayNameDefault = true; - av_name->mIsTemporaryName = true; - av_name->mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME; - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName " - << full_name - << LL_ENDL; - - // [Ansariel/Henri] - // Why ain't those set? In case of disabled display names - // we would have to parse LLAvatarName::mDisplayName to get - // first and lastname if we need them. So do it already here - // for convenience. - std::istringstream fname(full_name); - fname >> av_name->mLegacyFirstName >> av_name->mLegacyLastName; - // [/Ansariel/Henri] -} - // fills in av_name if it has it in the cache, even if expired (can check expiry time) // returns bool specifying if av_name was filled, false otherwise bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) @@ -623,38 +590,24 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) if (sRunning) { // ...only do immediate lookups when cache is running - if (useDisplayNames()) + std::map::iterator it = sCache.find(agent_id); + if (it != sCache.end()) { - // ...use display names cache - std::map::iterator it = sCache.find(agent_id); - if (it != sCache.end()) - { - *av_name = it->second; + *av_name = it->second; - // re-request name if entry is expired - if (av_name->mExpires < LLFrameTimer::getTotalSeconds()) - { - if (!isRequestPending(agent_id)) - { - LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get " - << "refresh agent " << agent_id - << LL_ENDL; - sAskQueue.insert(agent_id); - } - } - - return true; - } - } - else - { - // ...use legacy names cache - std::string full_name; - if (gCacheName->getFullName(agent_id, full_name)) + // re-request name if entry is expired + if (av_name->mExpires < LLFrameTimer::getTotalSeconds()) { - buildLegacyName(full_name, av_name); - return true; + if (!isRequestPending(agent_id)) + { + LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::get " + << "refresh agent " << agent_id + << LL_ENDL; + sAskQueue.insert(agent_id); + } } + + return true; } } @@ -669,35 +622,22 @@ bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) return false; } -const S32& LLAvatarNameCache::phoenix_name_system() +const S32& main_name_system() { static const LLCachedControl name_system("PhoenixNameSystem", 0); return name_system; } -// Return true when name has been set to Phoenix Name System Name, if not return false. -bool LLAvatarNameCache::getPNSName(const LLUUID& agent_id, std::string& name, const S32& name_system) +// Return true when name has been set to Name System Name, if not return false. +bool LLAvatarNameCache::getNSName(const LLUUID& agent_id, std::string& name, const S32& name_system) { LLAvatarName avatar_name; if (get(agent_id, &avatar_name)) - getPNSName(avatar_name, name, name_system); + name = avatar_name.getNSName(name_system); else return false; return true; } -// get() with callback compatible version of getPNSName -void LLAvatarNameCache::getPNSName(const LLAvatarName& avatar_name, std::string& name, const S32& name_system) -{ - switch (name_system) - { - case 0 : name = avatar_name.getLegacyName(); break; - case 1 : name = avatar_name.getCompleteName(); break; - case 2 : name = avatar_name.mDisplayName; break; - case 3 : name = avatar_name.getLegacyName() + (avatar_name.mIsDisplayNameDefault ? "" : " (" + avatar_name.mDisplayName + ")"); break; - default : name = avatar_name.getLegacyName(); break; - } -} - void LLAvatarNameCache::fireSignal(const LLUUID& agent_id, const callback_slot_t& slot, const LLAvatarName& av_name) @@ -714,30 +654,14 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag if (sRunning) { // ...only do immediate lookups when cache is running - if (useDisplayNames()) + std::map::iterator it = sCache.find(agent_id); + if (it != sCache.end()) { - // ...use new cache - std::map::iterator it = sCache.find(agent_id); - if (it != sCache.end()) + const LLAvatarName& av_name = it->second; + + if (av_name.mExpires > LLFrameTimer::getTotalSeconds()) { - const LLAvatarName& av_name = it->second; - - if (av_name.mExpires > LLFrameTimer::getTotalSeconds()) - { - // ...name already exists in cache, fire callback now - fireSignal(agent_id, slot, av_name); - return connection; - } - } - } - else - { - // ...use old name system - std::string full_name; - if (gCacheName->getFullName(agent_id, full_name)) - { - LLAvatarName av_name; - buildLegacyName(full_name, &av_name); + // ...name already exists in cache, fire callback now fireSignal(agent_id, slot, av_name); return connection; } @@ -778,7 +702,7 @@ bool LLAvatarNameCache::getForceDisplayNames() void LLAvatarNameCache::setForceDisplayNames(bool force) { sForceDisplayNames = force; - if ( (!sUseDisplayNames) && (force) ) + if ( (!LLAvatarName::useDisplayNames()) && (force) ) { setUseDisplayNames(true); } @@ -791,21 +715,20 @@ void LLAvatarNameCache::setUseDisplayNames(bool use) // We need to force the use of the "display names" cache when @shownames=n restricted (and disallow toggling it) use |= getForceDisplayNames(); // [/RLVa:KB] - if (use != sUseDisplayNames) + if (use != LLAvatarName::useDisplayNames()) { - sUseDisplayNames = use; - LL_DEBUGS("AvNameCache") << "Display names are now: " << (use ? "on" : "off") << LL_ENDL; - // flush our cache - sCache.clear(); - + LLAvatarName::setUseDisplayNames(use); mUseDisplayNamesSignal(); } } -bool LLAvatarNameCache::useDisplayNames() +void LLAvatarNameCache::setUseUsernames(bool use) { - // Must be both manually set on and able to look up names. - return sUseDisplayNames && !sNameLookupURL.empty(); + if (use != LLAvatarName::useUsernames()) + { + LLAvatarName::setUseUsernames(use); + mUseDisplayNamesSignal(); + } } void LLAvatarNameCache::erase(const LLUUID& agent_id) @@ -839,6 +762,7 @@ bool LLAvatarNameCache::expirationFromCacheControl(AIHTTPReceivedHeaders const& { bool fromCacheControl = false; F64 now = LLFrameTimer::getTotalSeconds(); + // Allow the header to override the default std::string cache_control; if (headers.getFirstValue("cache-control", cache_control)) diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index f98988769..e80b3d010 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -32,46 +32,41 @@ #include -class LLUUID; class AIHTTPReceivedHeaders; +class LLUUID; namespace LLAvatarNameCache { - typedef boost::signals2::signal use_display_name_signal_t; // Until the cache is set running, immediate lookups will fail and // async lookups will be queued. This allows us to block requests // until we know if the first region supports display names. - void initClass(bool running); + void initClass(bool running, bool usePeopleAPI); void cleanupClass(); + // Import/export the name cache to file. void importFile(std::istream& istr); void exportFile(std::ostream& ostr); - // On the viewer, usually a simulator capabilitity - // If empty, name cache will fall back to using legacy name - // lookup system + // On the viewer, usually a simulator capabilitity. + // If empty, name cache will fall back to using legacy name lookup system. void setNameLookupURL(const std::string& name_lookup_url); - // Do we have a valid lookup URL, hence are we trying to use the - // new display name lookup system? + // Do we have a valid lookup URL, i.e. are we trying to use the + // more recent display name lookup system? bool hasNameLookupURL(); + bool usePeopleAPI(); // Periodically makes a batch request for display names not already in - // cache. Call once per frame. + // cache. Called once per frame. void idle(); // If name is in cache, returns true and fills in provided LLAvatarName - // otherwise returns false + // otherwise returns false. bool get(const LLUUID& agent_id, LLAvatarName *av_name); - const S32& phoenix_name_system(); - // If get() succeeds, returns true and fills in name string - // via void function below, otherwise returns false - bool getPNSName(const LLUUID& agent_id, std::string& name, const S32& name_system = phoenix_name_system()); - // Perform a filling of name string according to Phoenix Name System, - // when we have an LLAvatarName already. - void getPNSName(const LLAvatarName& avatar_name, std::string& name, const S32& name_system = phoenix_name_system()); + // If get() succeeds, returns true and fills in name string via void function below, otherwise returns false + bool getNSName(const LLUUID& agent_id, std::string& name, const S32& name_system = main_name_system()); // Callback types for get() below typedef boost::signals2::signal< @@ -80,29 +75,29 @@ namespace LLAvatarNameCache typedef callback_signal_t::slot_type callback_slot_t; typedef boost::signals2::connection callback_connection_t; - // Fetches name information and calls callback. - // If name information is in cache, callback will be called immediately. + // Fetches name information and calls callbacks. + // If name information is in cache, callbacks will be called immediately. callback_connection_t get(const LLUUID& agent_id, callback_slot_t slot); - // Allow display names to be explicitly disabled for testing. + // Set display name: flips the switch and triggers the callbacks. void setUseDisplayNames(bool use); - bool useDisplayNames(); // [RLVa:KB] - Checked: 2010-12-08 (RLVa-1.4.0a) | Added: RLVa-1.2.2c bool getForceDisplayNames(); void setForceDisplayNames(bool force); // [/RLVa:KB] - void erase(const LLUUID& agent_id); - - /// Provide some fallback for agents that return errors - void handleAgentError(const LLUUID& agent_id); + void setUseUsernames(bool use); void insert(const LLUUID& agent_id, const LLAvatarName& av_name); + void erase(const LLUUID& agent_id); + + /// Provide some fallback for agents that return errors. + void handleAgentError(const LLUUID& agent_id); // Compute name expiration time from HTTP Cache-Control header, // or return default value, in seconds from epoch. - F64 nameExpirationFromHeaders(AIHTTPReceivedHeaders const& headers); + F64 nameExpirationFromHeaders(const AIHTTPReceivedHeaders& headers); void addUseDisplayNamesCallback(const use_display_name_signal_t::slot_type& cb); } diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index e14993dcf..180db3a4b 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -279,7 +279,9 @@ LLCacheName::Impl::Impl(LLMessageSystem* msg) LLCacheName::Impl::~Impl() { for_each(mCache.begin(), mCache.end(), DeletePairedPointer()); + mCache.clear(); for_each(mReplyQueue.begin(), mReplyQueue.end(), DeletePointer()); + mReplyQueue.clear(); } boost::signals2::connection LLCacheName::Impl::addPending(const LLUUID& id, const LLCacheNameCallback& callback) @@ -309,8 +311,10 @@ boost::signals2::connection LLCacheName::addObserver(const LLCacheNameCallback& bool LLCacheName::importFile(std::istream& istr) { LLSD data; - if(LLSDSerialize::fromXMLDocument(data, istr) < 1) + if(LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(data, istr)) + { return false; + } // We'll expire entries more than a week old U32 now = (U32)time(NULL); @@ -527,6 +531,7 @@ std::string LLCacheName::cleanFullName(const std::string& full_name) } //static +// Transform hard-coded name provided by server to a more legible username std::string LLCacheName::buildUsername(const std::string& full_name) { // rare, but handle hard-coded error names returned from server @@ -553,8 +558,9 @@ std::string LLCacheName::buildUsername(const std::string& full_name) return username; } - // if the input wasn't a correctly formatted legacy name just return it unchanged - return full_name; + // if the input wasn't a correctly formatted legacy name, just return it + // cleaned up from a potential terminal "Resident" + return cleanFullName(full_name); } //static @@ -562,13 +568,13 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) { //boost::regexp was showing up in the crashreporter, so doing //painfully manual parsing using substr. LF - S32 open_paren = complete_name.rfind(" ("); - S32 close_paren = complete_name.rfind(')'); + size_t open_paren = complete_name.rfind(" ("); + size_t close_paren = complete_name.rfind(')'); if (open_paren != std::string::npos && close_paren == complete_name.length()-1) { - S32 length = close_paren - open_paren - 2; + size_t length = llmax(close_paren - open_paren - 2, (size_t)0); std::string legacy_name = complete_name.substr(open_paren+2, length); if (legacy_name.length() > 0) @@ -577,7 +583,7 @@ std::string LLCacheName::buildLegacyName(const std::string& complete_name) LLStringUtil::toUpper(cap_letter); legacy_name = cap_letter + legacy_name.substr(1); - S32 separator = legacy_name.find('.'); + size_t separator = legacy_name.find('.'); if (separator != std::string::npos) { @@ -668,32 +674,18 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, ol // bool LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_group) { - if(id.isNull()) + if (id.notNull()) + if (LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id)) { - fullname = ""; - return false; - } - - LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); - if (entry) - { - if (entry->mIsGroup) - { - fullname = entry->mGroupName; - } - else - { - fullname = entry->mFirstName + " " + entry->mLastName; - } - is_group = entry->mIsGroup; + fullname = (is_group = entry->mIsGroup) ? entry->mGroupName : entry->mFirstName + " " + entry->mLastName; return true; } + fullname = ""; return false; } // - void LLCacheName::processPending() { const F32 SECS_BETWEEN_PROCESS = 0.1f; @@ -705,7 +697,7 @@ void LLCacheName::processPending() if(!impl.mUpstreamHost.isOk()) { lldebugs << "LLCacheName::processPending() - bad upstream host." - << llendl; + << LL_ENDL; return; } @@ -756,7 +748,7 @@ void LLCacheName::dump() << iter->first << " = (group) " << entry->mGroupName << " @ " << entry->mCreateTime - << llendl; + << LL_ENDL; } else { @@ -764,7 +756,7 @@ void LLCacheName::dump() << iter->first << " = " << buildFullName(entry->mFirstName, entry->mLastName) << " @ " << entry->mCreateTime - << llendl; + << LL_ENDL; } } } @@ -778,7 +770,7 @@ void LLCacheName::dumpStats() << " Pending=" << impl.mPendingQueue.size() << " Reply=" << impl.mReplyQueue.size() // << " Observers=" << impl.mSignal.size() - << llendl; + << LL_ENDL; } void LLCacheName::clear() @@ -935,7 +927,7 @@ void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup) << (isGroup ? "group" : "user") << " name, " << "but found " << (entry->mIsGroup ? "group" : "user") - << ": " << id << llendl; + << ": " << id << LL_ENDL; } else { diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 4c96ba0d3..9acd76221 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -40,7 +40,7 @@ typedef boost::signals2::signal LLCacheNameSignal; typedef LLCacheNameSignal::slot_type LLCacheNameCallback; -// Old callback with user data for compatability +// Old callback with user data for compatibility typedef void (*old_callback_t)(const LLUUID&, const std::string&, bool, void*); // Here's the theory: @@ -107,7 +107,7 @@ public: // otherwise, will request the data, and will call the callback when // available. There is no garuntee the callback will ever be called. boost::signals2::connection get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback); - + // bool getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_group); // diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index d4c83d674..9e83b9bd6 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -340,7 +340,8 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const // secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about // x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about // -LLUrlEntryAgent::LLUrlEntryAgent() +LLUrlEntryAgent::LLUrlEntryAgent() : + mAvatarNameCacheConnection() { mPattern = boost::regex(APP_HEADER_REGEX "/agent/[\\da-f-]+/\\w+", boost::regex::perl|boost::regex::icase); @@ -371,6 +372,8 @@ void LLUrlEntryAgent::callObservers(const std::string &id, void LLUrlEntryAgent::onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name) { + mAvatarNameCacheConnection.disconnect(); + std::string label = av_name.getCompleteName(); // received the agent name from the server - tell our observers @@ -456,9 +459,11 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa } else { - LLAvatarNameCache::get(agent_id, - boost::bind(&LLUrlEntryAgent::onAvatarNameCache, - this, _1, _2)); + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2)); addObserver(agent_id_string, url, cb); return LLTrans::getString("LoadingData"); } @@ -499,6 +504,10 @@ std::string localize_slapp_label(const std::string& url, const std::string& full { return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name; } + if (LLStringUtil::endsWith(url, "/removefriend")) + { + return LLTrans::getString("SLappAgentRemoveFriend") + " " + full_name; + } return full_name; } @@ -515,12 +524,15 @@ std::string LLUrlEntryAgent::getIcon(const std::string &url) // secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/(completename|displayname|username) // x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/(completename|displayname|username) // -LLUrlEntryAgentName::LLUrlEntryAgentName() +LLUrlEntryAgentName::LLUrlEntryAgentName() : + mAvatarNameCacheConnection() {} void LLUrlEntryAgentName::onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name) { + mAvatarNameCacheConnection.disconnect(); + std::string label = getName(av_name); // received the agent name from the server - tell our observers callObservers(id.asString(), label, mIcon); @@ -554,9 +566,11 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab } else { - LLAvatarNameCache::get(agent_id, - boost::bind(&LLUrlEntryAgentCompleteName::onAvatarNameCache, - this, _1, _2)); + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2)); addObserver(agent_id_string, url, cb); return LLTrans::getString("LoadingData"); } @@ -597,7 +611,7 @@ LLUrlEntryAgentDisplayName::LLUrlEntryAgentDisplayName() std::string LLUrlEntryAgentDisplayName::getName(const LLAvatarName& avatar_name) { - return avatar_name.mDisplayName; + return avatar_name.getDisplayName(); } // @@ -613,7 +627,7 @@ LLUrlEntryAgentUserName::LLUrlEntryAgentUserName() std::string LLUrlEntryAgentUserName::getName(const LLAvatarName& avatar_name) { - return avatar_name.mUsername.empty() ? avatar_name.getLegacyName() : avatar_name.mUsername; + return avatar_name.getAccountName(); } // @@ -1053,7 +1067,8 @@ LLUrlEntrySLLabel::LLUrlEntrySLLabel() std::string LLUrlEntrySLLabel::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { - return getLabelFromWikiLink(url); + std::string label = getLabelFromWikiLink(url); + return (!LLUrlRegistry::instance().hasUrl(label)) ? label : getUrl(url); } std::string LLUrlEntrySLLabel::getUrl(const std::string &string) const diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 0e2f4038f..e52fe8040 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -32,6 +32,7 @@ #include "lluicolor.h" #include "llstyle.h" +#include "llavatarname.h" #include "llhost.h" // for resolving parcel name by parcel id #include @@ -93,7 +94,7 @@ public: virtual std::string getLocation(const std::string &url) const { return ""; } /// Should this link text be underlined only when mouse is hovered over it? - virtual bool underlineOnHoverOnly(const std::string &string) const { return false; } + virtual bool underlineOnHoverOnly(const std::string &string) const { return true; } // virtual LLUUID getID(const std::string &string) const { return LLUUID::null; } @@ -171,6 +172,13 @@ class LLUrlEntryAgent : public LLUrlEntryBase { public: LLUrlEntryAgent(); + ~LLUrlEntryAgent() + { + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + } /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); /*virtual*/ std::string getIcon(const std::string &url); /*virtual*/ std::string getTooltip(const std::string &string) const; @@ -181,6 +189,7 @@ protected: /*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon); private: void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); + boost::signals2::connection mAvatarNameCacheConnection; }; /// @@ -192,6 +201,13 @@ class LLUrlEntryAgentName : public LLUrlEntryBase, public boost::signals2::track { public: LLUrlEntryAgentName(); + ~LLUrlEntryAgentName() + { + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + } /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); //*virtual*/ LLStyle::Params getStyle() const; protected: @@ -199,6 +215,7 @@ protected: virtual std::string getName(const LLAvatarName& avatar_name) = 0; private: void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); + boost::signals2::connection mAvatarNameCacheConnection; }; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 633294259..81e21494c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9900,17 +9900,6 @@ This should be as low as possible, but too low may break functionality Value 0 - LegacyMultiAttachmentSupport - - Comment - Converts legacy "secondary attachment points" to multi-attachments for other avatars - Persist - 1 - Type - Boolean - Value - 1 - LimitDragDistance Comment @@ -16785,6 +16774,17 @@ This should be as low as possible, but too low may break functionality Value 0 + UsePeopleAPI + + Comment + Use the people API cap for avatar name fetching, use old legacy protocol if false. Requires restart. + Persist + 1 + Type + Boolean + Value + 1 + UseStartScreen Comment diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index ddbfca284..c1f6253ed 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -219,9 +219,7 @@ struct ProfCtrlListAccum : public LLControlGroup::ApplyFunctor #endif //PROF_CTRL_CALLS void spew_key_to_name(const LLUUID& targetKey, const LLAvatarName& av_name) { - std::string object_name; - LLAvatarNameCache::getPNSName(av_name, object_name); - cmdline_printchat(llformat("%s: %s", targetKey.asString().c_str(), object_name.c_str())); + cmdline_printchat(llformat("%s: %s", targetKey.asString().c_str(), av_name.getNSName().c_str())); } bool cmd_line_chat(std::string revised_text, EChatType type) { diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 1282ba0cc..963a546a0 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -131,10 +131,10 @@ void LLAvatarActions::removeFriendsDialog(const uuid_vec_t& ids) if(ids.size() == 1) { LLUUID agent_id = ids[0]; - std::string av_name; - if(LLAvatarNameCache::getPNSName(agent_id, av_name)) + LLAvatarName av_name; + if(LLAvatarNameCache::get(agent_id, &av_name)) { - args["NAME"] = av_name; + args["NAME"] = av_name.getNSName(); } msgType = "RemoveFromFriends"; @@ -354,19 +354,11 @@ static void on_avatar_name_show_profile(const LLUUID& agent_id, const LLAvatarNa } else { - std::string username = av_name.mUsername; - if (username.empty()) - { - username = LLCacheName::buildUsername(av_name.mDisplayName); - } - - llinfos << "opening web profile for " << username << llendl; - std::string url = getProfileURL(username); + std::string url = getProfileURL(av_name.getAccountName()); // PROFILES: open in webkit window LLFloaterWebContent::Params p; - p.url(url). - id(agent_id.asString()); + p.url(url).id(agent_id.asString()); LLFloaterWebProfile::showInstance(get_profile_floater_name(agent_id), p); } } @@ -423,14 +415,14 @@ void LLAvatarActions::hideProfile(const LLUUID& id) // static void LLAvatarActions::showOnMap(const LLUUID& id) { - std::string av_name; - if (!LLAvatarNameCache::getPNSName(id, av_name)) + LLAvatarName av_name; + if (!LLAvatarNameCache::get(id, &av_name)) { LLAvatarNameCache::get(id, boost::bind(&LLAvatarActions::showOnMap, id)); return; } - gFloaterWorldMap->trackAvatar(id, av_name); + gFloaterWorldMap->trackAvatar(id, av_name.getNSName()); LLFloaterWorldMap::show(true); } @@ -519,7 +511,7 @@ void LLAvatarActions::on_avatar_name_cache_teleport_request(const LLUUID& id, co name = RlvStrings::getAnonym(av_name.getLegacyName()); else // [RLVa:KB] - LLAvatarNameCache::getPNSName(av_name, name); + name = av_name.getNSName(); notification["NAME"] = name; LLSD payload; @@ -841,7 +833,7 @@ void LLAvatarActions::buildResidentsString(std::vector avatar_name const std::string& separator = LLTrans::getString("words_separator"); for (std::vector::const_iterator it = avatar_names.begin(); ; ) { - residents_string.append((*it).getCompleteName()); + residents_string.append((*it).getNSName()); if (++it == avatar_names.end()) { break; diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 91bc47e7b..2c0fc697f 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -38,35 +38,29 @@ #include "llcallingcard.h" -#include #include -//#include #include "indra_constants.h" -#include "llcachename.h" +//#include "llcachename.h" #include "llstl.h" #include "lltimer.h" #include "lluuid.h" #include "message.h" #include "llagent.h" -#include "llbutton.h" -//#include "llinventory.h" -#include "llinventorymodel.h" +#include "llavatarnamecache.h" #include "llinventoryobserver.h" +#include "llinventorymodel.h" #include "llnotifications.h" -#include "llnotificationsutil.h" #include "llresmgr.h" #include "llimview.h" +#include "lltrans.h" #include "llviewercontrol.h" -#include "llviewernetwork.h" #include "llviewerobjectlist.h" -#include "llviewerwindow.h" #include "llvoavatar.h" +#include "llavataractions.h" #include "llimview.h" #include "llimpanel.h" -#include "llavatarname.h" -#include "llavatarnamecache.h" ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs @@ -111,8 +105,6 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, LLAvatarTracker::LLAvatarTracker() : mTrackingData(NULL), mTrackedAgentValid(false), - //mInventory(NULL), - //mInventoryObserver(NULL), mModifyMask(0x0) { } @@ -121,7 +113,9 @@ LLAvatarTracker::~LLAvatarTracker() { deleteTrackingData(); std::for_each(mObservers.begin(), mObservers.end(), DeletePointer()); + mObservers.clear(); std::for_each(mBuddyInfo.begin(), mBuddyInfo.end(), DeletePairedPointer()); + mBuddyInfo.clear(); } void LLAvatarTracker::track(const LLUUID& avatar_id, const std::string& name) @@ -184,13 +178,13 @@ LLVector3d LLAvatarTracker::getGlobalPos() if(!mTrackedAgentValid || !mTrackingData) return LLVector3d(); LLVector3d global_pos; - LLVOAvatar* avatarp = gObjectList.findAvatar(mTrackingData->mAvatarID); - if(avatarp && !avatarp->isDead()) + LLVOAvatar* av = gObjectList.findAvatar(mTrackingData->mAvatarID); + if(av && !av->isDead()) { - global_pos = avatarp->getPositionGlobal(); + global_pos = av->getPositionGlobal(); // HACK - for making the tracker point above the avatar's head // rather than its groin - global_pos.mdV[VZ] += 0.7f * (avatarp->mBodySize.mV[VZ] + avatarp->mAvatarOffset.mV[VZ]); + global_pos.mdV[VZ] += 0.7f * (av->mBodySize.mV[VZ] + av->mAvatarOffset.mV[VZ]); mTrackingData->mGlobalPositionEstimate = global_pos; } @@ -210,10 +204,10 @@ void LLAvatarTracker::getDegreesAndDist(F32& rot, LLVector3d global_pos; - LLVOAvatar* avatarp = gObjectList.findAvatar(mTrackingData->mAvatarID); - if(avatarp && !avatarp->isDead()) + LLViewerObject* object = gObjectList.findObject(mTrackingData->mAvatarID); + if(object && !object->isDead()) { - global_pos = avatarp->getPositionGlobal(); + global_pos = object->getPositionGlobal(); mTrackingData->mGlobalPositionEstimate = global_pos; } else @@ -272,7 +266,7 @@ S32 LLAvatarTracker::addBuddyList(const LLAvatarTracker::buddy_map_t& buds) << ", " << (mBuddyInfo[agent_id]->isOnline() ? "Online" : "Offline") << ", TO: " << mBuddyInfo[agent_id]->getRightsGrantedTo() << ", FROM: " << mBuddyInfo[agent_id]->getRightsGrantedFrom() - << llendl; + << LL_ENDL; } else { @@ -282,7 +276,7 @@ S32 LLAvatarTracker::addBuddyList(const LLAvatarTracker::buddy_map_t& buds) << " [" << (e_r->isOnline() ? "Online" : "Offline") << "->" << (n_r->isOnline() ? "Online" : "Offline") << ", " << e_r->getRightsGrantedTo() << "->" << n_r->getRightsGrantedTo() << ", " << e_r->getRightsGrantedTo() << "->" << n_r->getRightsGrantedTo() - << "]" << llendl; + << "]" << LL_ENDL; } } notifyObservers(); @@ -315,6 +309,7 @@ void LLAvatarTracker::terminateBuddy(const LLUUID& id) msg->nextBlock("ExBlock"); msg->addUUID("OtherID", id); gAgent.sendReliableMessage(); + addChangedMask(LLFriendObserver::REMOVE, id); delete buddy; } @@ -345,7 +340,7 @@ void LLAvatarTracker::setBuddyOnline(const LLUUID& id, bool is_online) else { llwarns << "!! No buddy info found for " << id - << ", setting to " << (is_online ? "Online" : "Offline") << llendl; + << ", setting to " << (is_online ? "Online" : "Offline") << LL_ENDL; } } @@ -462,7 +457,7 @@ void LLAvatarTracker::findAgent() msg->nextBlockFast(_PREHASH_AgentBlock); msg->addUUIDFast(_PREHASH_Hunter, gAgentID); msg->addUUIDFast(_PREHASH_Prey, mTrackingData->mAvatarID); - msg->addU32Fast(_PREHASH_SpaceIP, 0); // will get filled in by simulator + msg->addIPAddrFast(_PREHASH_SpaceIP, 0); // will get filled in by simulator // msg->nextBlockFast(_PREHASH_LocationBlock); const F64 NO_LOCATION = 0.0; msg->addF64Fast(_PREHASH_GlobalX, NO_LOCATION); @@ -640,20 +635,40 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg) { std::string fullname; LLSD args; - if (LLAvatarNameCache::getPNSName(agent_id, fullname)) + if (LLAvatarNameCache::getNSName(agent_id, fullname)) args["NAME"] = fullname; LLSD payload; payload["from_id"] = agent_id; if(LLRelationship::GRANT_MODIFY_OBJECTS & new_rights) { - LLNotificationsUtil::add("GrantedModifyRights",args, payload); + LLNotifications::instance().add("GrantedModifyRights",args, payload); } else { - LLNotificationsUtil::add("RevokedModifyRights",args, payload); + LLNotifications::instance().add("RevokedModifyRights",args, payload); } } + // + if ((mBuddyInfo[agent_id]->getRightsGrantedFrom() ^ new_rights) & LLRelationship::GRANT_MAP_LOCATION) + { + std::string fullname; + LLSD args; + if (LLAvatarNameCache::getNSName(agent_id, fullname)) + args["NAME"] = fullname; + + LLSD payload; + payload["from_id"] = agent_id; + if (LLRelationship::GRANT_MAP_LOCATION & new_rights) + { + LLNotifications::instance().add("GrantedMapRights", args, payload); + } + else + { + LLNotifications::instance().add("RevokedMapRights", args, payload); + } + } + // (mBuddyInfo[agent_id])->setRightsFrom(new_rights); } } @@ -697,7 +712,7 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) else { llwarns << "Received online notification for unknown buddy: " - << agent_id << " is " << (online ? "ONLINE" : "OFFLINE") << llendl; + << agent_id << " is " << (online ? "ONLINE" : "OFFLINE") << LL_ENDL; } if(tracking_id == agent_id) @@ -711,9 +726,7 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) if(chat_notify) { // Look up the name of this agent for the notification - LLAvatarNameCache::get(agent_id, - boost::bind(&on_avatar_name_cache_notify, - _1, _2, online, payload)); + LLAvatarNameCache::get(agent_id,boost::bind(&on_avatar_name_cache_notify,_1, _2, online, payload)); } mModifyMask |= LLFriendObserver::ONLINE; @@ -729,22 +742,33 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id, { // Popup a notify box with online status of this agent // Use display name only because this user is your friend - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); LLSD args; - args["NAME"] = name; + args["NAME"] = av_name.getNSName(); + args["STATUS"] = online ? LLTrans::getString("OnlineStatus") : LLTrans::getString("OfflineStatus"); // Popup a notify box with online status of this agent - LLNotificationPtr notification = LLNotificationsUtil::add(online ? "FriendOnline" : "FriendOffline", args, payload); + LLNotificationPtr notification; + if (online) + { + notification = + LLNotifications::instance().add("FriendOnlineOffline", + args, + payload, + boost::bind(&LLAvatarActions::startIM, agent_id)); + } + else + { + notification = + LLNotifications::instance().add("FriendOnlineOffline", args, payload); + } // If there's an open IM session with this agent, send a notification there too. LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); - LLFloaterIMPanel *floater = gIMMgr->findFloaterBySession(session_id); - if (floater) + if (LLFloaterIMPanel* floater = gIMMgr->findFloaterBySession(session_id)) { - std::string notifyMsg = notification->getMessage(); - if (!notifyMsg.empty()) - floater->addHistoryLine(notifyMsg,gSavedSettings.getColor4("SystemChatColor")); + std::string notify_msg = notification->getMessage(); + if (!notify_msg.empty()) + floater->addHistoryLine(notify_msg, gSavedSettings.getColor4("SystemChatColor")); } } @@ -812,7 +836,7 @@ void LLTrackingData::agentFound(const LLUUID& prey, if(prey != mAvatarID) { llwarns << "LLTrackingData::agentFound() - found " << prey - << " but looking for " << mAvatarID << llendl; + << " but looking for " << mAvatarID << LL_ENDL; } mHaveInfo = true; mAgentGone.setTimerExpirySec(OFFLINE_SECONDS); @@ -821,8 +845,8 @@ void LLTrackingData::agentFound(const LLUUID& prey, bool LLTrackingData::haveTrackingInfo() { - LLVOAvatar* avatarp = gObjectList.findAvatar(mAvatarID); - if(avatarp && !avatarp->isDead()) + LLViewerObject* object = gObjectList.findObject(mAvatarID); + if(object && !object->isDead()) { mCoarseLocationTimer.checkExpirationAndReset(COARSE_FREQUENCY); mUpdateTimer.setTimerExpirySec(FIND_FREQUENCY); @@ -876,7 +900,7 @@ bool LLCollectMappableBuddies::operator()(const LLUUID& buddy_id, LLRelationship { LLAvatarName av_name; LLAvatarNameCache::get( buddy_id, &av_name); - buddy_map_t::value_type value(av_name.mDisplayName, buddy_id); + buddy_map_t::value_type value(av_name.getDisplayName(), buddy_id); if(buddy->isOnline() && buddy->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION)) { mMappable.insert(value); @@ -898,7 +922,9 @@ bool LLCollectOnlineBuddies::operator()(const LLUUID& buddy_id, LLRelationship* const S32& friend_name_system(); bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* buddy) { - LLAvatarNameCache::getPNSName(buddy_id, mFullName, friend_name_system()); + LLAvatarName av_name; + LLAvatarNameCache::get(buddy_id, &av_name); + mFullName = av_name.getNSName(friend_name_system()); buddy_map_t::value_type value(mFullName, buddy_id); if(buddy->isOnline()) { @@ -910,5 +936,3 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud } return true; } - - diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index 6b47c2680..259213792 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -546,7 +546,7 @@ void LLFloaterAvatarList::updateAvatarList() const LLUUID& avid = avatar_ids[i]; std::string name; static const LLCachedControl namesystem("RadarNameSystem"); - if (!LLAvatarNameCache::getPNSName(avid, name, namesystem)) continue; //prevent (Loading...) + if (!LLAvatarNameCache::getNSName(avid, name, namesystem)) continue; //prevent (Loading...) LLVector3d position = positions[i]; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 389acdbe0..3c9ad33a9 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -53,6 +53,7 @@ #include "lldraghandle.h" #include "message.h" +//#include "llsdserialize.h" //put it back as a member once the legacy path is out? static std::map sAvatarNameMap; @@ -333,9 +334,9 @@ void LLFloaterAvatarPicker::populateNearMe() else { element["columns"][0]["column"] = "name"; - element["columns"][0]["value"] = av_name.mDisplayName; + element["columns"][0]["value"] = av_name.getDisplayName(); element["columns"][1]["column"] = "username"; - element["columns"][1]["value"] = av_name.mUsername; + element["columns"][1]["value"] = av_name.getUserName(); sAvatarNameMap[av] = av_name; } @@ -514,7 +515,6 @@ protected: else { llwarns << "avatar picker failed " << dumpResponse() << LL_ENDL; - } } @@ -670,8 +670,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* // Not for us if (agent_id != gAgent.getID()) return; - if (!instanceExists()) return; - LLFloaterAvatarPicker* floater = getInstance(); + LLFloaterAvatarPicker* floater = instanceExists() ? getInstance() : NULL; // floater is closed or these are not results from our last request if (NULL == floater || query_id != floater->mQueryID) @@ -713,9 +712,7 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* found_one = TRUE; LLAvatarName av_name; - av_name.mLegacyFirstName = first_name; - av_name.mLegacyLastName = last_name; - av_name.mDisplayName = avatar_name; + av_name.fromString(avatar_name); const LLUUID& agent_id = avatar_id; sAvatarNameMap[agent_id] = av_name; diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp index a00cfb8bf..3aca56f75 100644 --- a/indra/newview/llfloaterdisplayname.cpp +++ b/indra/newview/llfloaterdisplayname.cpp @@ -40,53 +40,12 @@ #include "llagent.h" -LLFloaterDisplayName* LLFloaterDisplayName::sInstance = NULL; - -LLFloaterDisplayName::LLFloaterDisplayName() +LLFloaterDisplayName::LLFloaterDisplayName(const LLSD&) : LLFloater(std::string("Display Names Floater")) { - LLFloaterDisplayName::sInstance = this; + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_display_name.xml"); } -// virtual -LLFloaterDisplayName::~LLFloaterDisplayName() -{ - - LLFloaterDisplayName::sInstance = NULL; - -} - -BOOL LLFloaterDisplayName::postBuild() -{ - childSetAction("reset_btn", onReset, this); - childSetAction("cancel_btn", onCancel, this); - childSetAction("save_btn", onSave, this); - - center(); - - return TRUE; -} - -void LLFloaterDisplayName::show() -{ - if (LLFloaterDisplayName::sInstance) - { - LLFloaterDisplayName::sInstance->open(); /*Flawfinder: ignore*/ - return; - } - - - LLFloaterDisplayName *self = new LLFloaterDisplayName(); - - // Builds and adds to gFloaterView - LLUICtrlFactory::getInstance()->buildFloater(self, "floater_display_name.xml"); - - // Fix up rectangle - - self->open(); /*Flawfinder: ignore*/ -} - - void LLFloaterDisplayName::onOpen() { getChild("display_name_editor")->clear(); @@ -112,16 +71,10 @@ void LLFloaterDisplayName::onOpen() std::string hour = next_update_local.asString().substr(11,2); std::string minute = next_update_local.asString().substr(14,2); std::string second = next_update_local.asString().substr(17,2); - std::string next_update_string_date = - llformat("%s/%s/%s",year.c_str(),month.c_str(), - day.c_str()); - std::string next_update_string_time = - llformat("%s:%s:%s",hour.c_str(),minute.c_str(), - second.c_str()); - getChild("lockout_text")->setTextArg("[DATE]", - next_update_string_date); - getChild("lockout_text")->setTextArg("[TIME]", - next_update_string_time); + std::string next_update_string_date = llformat("%s/%s/%s",year.c_str(),month.c_str(), day.c_str()); + std::string next_update_string_time = llformat("%s:%s:%s",hour.c_str(),minute.c_str(), second.c_str()); + getChild("lockout_text")->setTextArg("[DATE]", next_update_string_date); + getChild("lockout_text")->setTextArg("[TIME]", next_update_string_time); getChild("lockout_text")->setVisible(true); getChild("save_btn")->setEnabled(false); getChild("display_name_editor")->setEnabled(false); @@ -139,6 +92,16 @@ void LLFloaterDisplayName::onOpen() } } +BOOL LLFloaterDisplayName::postBuild() +{ + getChild("reset_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onReset, this)); + getChild("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onCancel, this)); + getChild("save_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onSave, this)); + + center(); + + return TRUE; +} void LLFloaterDisplayName::onCacheSetName(bool success, const std::string& reason, @@ -151,10 +114,6 @@ void LLFloaterDisplayName::onCacheSetName(bool success, LLSD args; args["DISPLAY_NAME"] = content["display_name"]; LLNotificationsUtil::add("SetDisplayNameSuccess", args); - - // Re-fetch my name, as it may have been sanitized by the service - //LLAvatarNameCache::get(getAvatarId(), - // boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); return; } @@ -167,7 +126,7 @@ void LLFloaterDisplayName::onCacheSetName(bool success, if (!error_tag.empty() && LLNotificationTemplates::getInstance()->templateExists(error_tag)) { - LLNotifications::instance().add(error_tag); + LLNotificationsUtil::add(error_tag); return; } @@ -186,34 +145,30 @@ void LLFloaterDisplayName::onCacheSetName(bool success, LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } -void LLFloaterDisplayName::onCancel(void* data) +void LLFloaterDisplayName::onCancel() { - LLFloaterDisplayName* self = (LLFloaterDisplayName*)data; - self->setVisible(false); + setVisible(false); } -void LLFloaterDisplayName::onReset(void* data) +void LLFloaterDisplayName::onReset() { - LLFloaterDisplayName* self = (LLFloaterDisplayName*)data; - if (LLAvatarNameCache::useDisplayNames()) + if (LLAvatarNameCache::hasNameLookupURL()) { - LLViewerDisplayName::set("", - boost::bind(&LLFloaterDisplayName::onCacheSetName, self, _1, _2, _3)); + LLViewerDisplayName::set("", boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); } else { LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } - self->setVisible(false); + setVisible(false); } -void LLFloaterDisplayName::onSave(void* data) +void LLFloaterDisplayName::onSave() { - LLFloaterDisplayName* self = (LLFloaterDisplayName*)data; - std::string display_name_utf8 = self->getChild("display_name_editor")->getValue().asString(); - std::string display_name_confirm = self->getChild("display_name_confirm")->getValue().asString(); + std::string display_name_utf8 = getChild("display_name_editor")->getValue().asString(); + std::string display_name_confirm = getChild("display_name_confirm")->getValue().asString(); if (display_name_utf8.compare(display_name_confirm)) { @@ -231,17 +186,16 @@ void LLFloaterDisplayName::onSave(void* data) return; } - if (LLAvatarNameCache::useDisplayNames()) + if (LLAvatarNameCache::hasNameLookupURL()) { - LLViewerDisplayName::set(display_name_utf8, - boost::bind(&LLFloaterDisplayName::onCacheSetName, self, _1, _2, _3)); + LLViewerDisplayName::set(display_name_utf8, boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); } else { LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); } - self->setVisible(false); + setVisible(false); } diff --git a/indra/newview/llfloaterdisplayname.h b/indra/newview/llfloaterdisplayname.h index 2d6bbf198..0e642706b 100644 --- a/indra/newview/llfloaterdisplayname.h +++ b/indra/newview/llfloaterdisplayname.h @@ -28,24 +28,21 @@ class LLFloaterDisplayName : public LLFloater +, public LLFloaterSingleton { public: - LLFloaterDisplayName(); - virtual ~LLFloaterDisplayName(); + LLFloaterDisplayName(const LLSD&); + virtual ~LLFloaterDisplayName() { } /*virtual*/ BOOL postBuild(); - static void onSave(void* data); - static void onReset(void* data); - static void onCancel(void* data); - static void show(); + void onSave(); + void onReset(); + void onCancel(); /*virtual*/ void onOpen(); private: void onCacheSetName(bool success, const std::string& reason, const LLSD& content); -protected: - static LLFloaterDisplayName* sInstance; - }; diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index 14a684bbe..cf76d2cfc 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -330,9 +330,7 @@ const S32& friend_name_system() static void update_friend_item(LLScrollListItem* item, const LLAvatarName& avname) { - std::string name; - LLAvatarNameCache::getPNSName(avname, name, friend_name_system()); - item->getColumn(1)->setValue(name); + item->getColumn(1)->setValue(avname.getNSName(friend_name_system())); } void LLPanelFriends::addFriend(const LLUUID& agent_id) @@ -343,7 +341,7 @@ void LLPanelFriends::addFriend(const LLUUID& agent_id) bool isOnline = relation_info->isOnline(); std::string fullname; - bool have_name = LLAvatarNameCache::getPNSName(agent_id, fullname, friend_name_system()); + bool have_name = LLAvatarNameCache::getNSName(agent_id, fullname, friend_name_system()); if (!have_name) gCacheName->getFullName(agent_id, fullname); LLScrollListItem::Params element; @@ -417,7 +415,7 @@ void LLPanelFriends::updateFriendItem(const LLUUID& agent_id, const LLRelationsh bool isOnline = info->isOnline(); std::string fullname; - if (LLAvatarNameCache::getPNSName(agent_id, fullname, friend_name_system())) + if (LLAvatarNameCache::getNSName(agent_id, fullname, friend_name_system())) { itemp->getColumn(LIST_FRIEND_UPDATE_GEN)->setValue(info->getChangeSerialNum()); } @@ -847,7 +845,7 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& rights, EGrantRevoke comm { LLSD args; std::string fullname; - if (LLAvatarNameCache::getPNSName(rights.begin()->first, fullname, friend_name_system())) + if (LLAvatarNameCache::getNSName(rights.begin()->first, fullname, friend_name_system())) args["NAME"] = fullname; LLNotificationsUtil::add(command == GRANT ? "GrantModifyRights" : "RevokeModifyRights", diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 23db2f4e8..e6a6b0316 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1303,7 +1303,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) if(texture_ctrl) { lldebugs << "Detail Texture " << i << ": " - << compp->getDetailTextureID(i) << llendl; + << compp->getDetailTextureID(i) << LL_ENDL; LLUUID tmp_id(compp->getDetailTextureID(i)); texture_ctrl->setImageAssetID(tmp_id); } @@ -2260,7 +2260,7 @@ void LLPanelEstateInfo::refreshFromEstate() const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); getChild("estate_name")->setValue(estate_info.getName()); - LLAvatarNameCache::get(estate_info.getOwnerID(), boost::bind(&LLPanelEstateInfo::setOwnerPNSName, this, _1, _2)); + LLAvatarNameCache::get(estate_info.getOwnerID(), boost::bind(&LLPanelEstateInfo::setOwnerName, this, boost::bind(&LLAvatarName::getNSName, _2, main_name_system()))); getChild("externally_visible_check")->setValue(estate_info.getIsExternallyVisible()); getChild("voice_chat_check")->setValue(estate_info.getAllowVoiceChat()); @@ -2425,13 +2425,6 @@ void LLPanelEstateInfo::setOwnerName(const std::string& name) getChild("estate_owner")->setValue(LLSD(name)); } -void LLPanelEstateInfo::setOwnerPNSName(const LLUUID& agent_id, const LLAvatarName& av_name) -{ - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - setOwnerName(name); -} - void LLPanelEstateInfo::clearAccessLists() { LLNameListCtrl* name_list = getChild("allowed_avatar_name_list"); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 128deaebe..beb6893e1 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -322,7 +322,6 @@ public: const std::string getOwnerName() const; void setOwnerName(const std::string& name); - void setOwnerPNSName(const LLUUID& agent_id, const LLAvatarName& av_name); protected: virtual BOOL sendUpdate(); diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 19cc09f55..08cef05d7 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -52,7 +52,6 @@ // viewer project includes #include "llagent.h" -#include "llagentui.h" #include "llbutton.h" #include "lltexturectrl.h" #include "llscrolllistctrl.h" @@ -80,14 +79,12 @@ #include "llviewernetwork.h" #include "llassetuploadresponders.h" +#include "llagentui.h" #include "lltrans.h" const U32 INCLUDE_SCREENSHOT = 0x01 << 0; -class AIHTTPTimeoutPolicy; -extern AIHTTPTimeoutPolicy userReportResponder_timeout; - //----------------------------------------------------------------------------- // Globals //----------------------------------------------------------------------------- @@ -106,7 +103,8 @@ LLFloaterReporter::LLFloaterReporter() mPicking( FALSE), mPosition(), mCopyrightWarningSeen( FALSE ), - mResourceDatap(new LLResourceData()) + mResourceDatap(new LLResourceData()), + mAvatarNameCacheConnection() { LLUICtrlFactory::getInstance()->buildFloater(this, "floater_report_abuse.xml"); } @@ -174,6 +172,7 @@ BOOL LLFloaterReporter::postBuild() pick_btn->setImages(std::string("UIImgFaceUUID"), std::string("UIImgFaceSelectedUUID") ); childSetAction("pick_btn", onClickObjPicker, this); + childSetAction("select_abuser", boost::bind(&LLFloaterReporter::onClickSelectAbuser, this)); childSetAction("send_btn", onClickSend, this); @@ -190,6 +189,11 @@ BOOL LLFloaterReporter::postBuild() // virtual LLFloaterReporter::~LLFloaterReporter() { + if (mAvatarNameCacheConnection.connected()) + { + mAvatarNameCacheConnection.disconnect(); + } + // child views automatically deleted mObjectID = LLUUID::null; @@ -254,14 +258,6 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) if (regionp) { getChild("sim_field")->setValue(regionp->getName()); -// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) -/* - if ( (rlv_handler_t::isEnabled()) && (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ) - { - childSetText("sim_field", RlvStrings::getString(RLV_STRING_HIDDEN_REGION)); - } -*/ -// [/RLVa:KB] LLVector3d global_pos; global_pos.setVec(objectp->getPositionRegion()); setPosBox(global_pos); @@ -315,26 +311,25 @@ void LLFloaterReporter::callbackAvatarID(const uuid_vec_t& ids, const std::vecto void LLFloaterReporter::setFromAvatarID(const LLUUID& avatar_id) { mAbuserID = mObjectID = avatar_id; - std::string avatar_link; - if (LLAvatarNameCache::getPNSName(avatar_id, avatar_link)) + if (mAvatarNameCacheConnection.connected()) { - getChild("owner_name")->setValue(avatar_link); - getChild("object_name")->setValue(avatar_link); - getChild("abuser_name_edit")->setValue(avatar_link); - return; + mAvatarNameCacheConnection.disconnect(); } - - LLAvatarNameCache::get(avatar_id, boost::bind(&LLFloaterReporter::onAvatarNameCache, this, _1, _2)); + mAvatarNameCacheConnection = LLAvatarNameCache::get(avatar_id, boost::bind(&LLFloaterReporter::onAvatarNameCache, this, _1, _2)); } void LLFloaterReporter::onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name) { - std::string avatar_link; - LLAvatarNameCache::getPNSName(av_name, avatar_link); - getChild("owner_name")->setValue(avatar_link); - getChild("object_name")->setValue(avatar_link); - getChild("abuser_name_edit")->setValue(avatar_link); + mAvatarNameCacheConnection.disconnect(); + + if (mObjectID == avatar_id) + { + mOwnerName = av_name.getNSName(); + getChild("owner_name")->setValue(av_name.getNSName()); + getChild("object_name")->setValue(av_name.getNSName()); + getChild("abuser_name_edit")->setValue(av_name.getNSName()); + } } @@ -472,7 +467,6 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) } } - // static void LLFloaterReporter::show(const LLUUID& object_id, const std::string& avatar_name) { @@ -598,6 +592,7 @@ LLSD LLFloaterReporter::gatherReport() const char* platform = "Lnx"; #elif LL_SOLARIS const char* platform = "Sol"; + const char* short_platform = "O:S"; #else const char* platform = "???"; #endif @@ -718,23 +713,24 @@ public: /*virtual*/ char const* getName(void) const { return "LLUserReportScreenshotResponder"; } }; -class LLUserReportResponder : public LLHTTPClient::ResponderWithResult +class LLUserReportResponder : public LLHTTPClient::ResponderWithCompleted { + LOG_CLASS(LLUserReportResponder); public: LLUserReportResponder() { } - /*virtual*/ void httpFailure(void) - { - // *TODO do some user messaging here - LLUploadDialog::modalUploadFinished(); - } - /*virtual*/ void httpSuccess(void) +private: + void httpCompleted() { + if (!isGoodStatus(mStatus)) + { + // *TODO do some user messaging here + LL_WARNS("UserReport") << dumpResponse() << LL_ENDL; + } // we don't care about what the server returns LLUploadDialog::modalUploadFinished(); } - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return userReportResponder_timeout; } - /*virtual*/ char const* getName(void) const { return "LLUserReportResponder"; } + char const* getName() const { return "LLUserReportResponder"; } }; void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url, const LLSD& report) diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h index 1b10ed671..71f478e52 100644 --- a/indra/newview/llfloaterreporter.h +++ b/indra/newview/llfloaterreporter.h @@ -141,6 +141,7 @@ private: std::list mMCDList; std::string mDefaultSummary; LLResourceData* mResourceDatap; + boost::signals2::connection mAvatarNameCacheConnection; }; #endif diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 9451908c7..0da418021 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -184,27 +184,33 @@ void LLPanelScriptLimitsInfo::updateChild(LLUICtrl* child_ctr) // Responders ///---------------------------------------------------------------------------- -void fetchScriptLimitsRegionInfoResponder::httpSuccess(void) +void fetchScriptLimitsRegionInfoResponder::httpSuccess() { + const LLSD& content = getContent(); + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } //we don't need to test with a fake response here (shouldn't anyway) #ifdef DUMP_REPLIES_TO_LLINFOS - LLSDNotationStreamer notation_streamer(mContent); + LLSDNotationStreamer notation_streamer(content); std::ostringstream nice_llsd; nice_llsd << notation_streamer; OSMessageBox(nice_llsd.str(), "main cap response:", 0); - llinfos << "main cap response:" << mContent << llendl; + llinfos << "main cap response:" << content << LL_ENDL; #endif // at this point we have an llsd which should contain ether one or two urls to the services we want. // first we look for the details service: - if(mContent.has("ScriptResourceDetails")) + if(content.has("ScriptResourceDetails")) { - LLHTTPClient::get(mContent["ScriptResourceDetails"], new fetchScriptLimitsRegionDetailsResponder(mInfo)); + LLHTTPClient::get(content["ScriptResourceDetails"], new fetchScriptLimitsRegionDetailsResponder(mInfo)); } else { @@ -216,19 +222,20 @@ void fetchScriptLimitsRegionInfoResponder::httpSuccess(void) } // then the summary service: - if(mContent.has("ScriptResourceSummary")) + if(content.has("ScriptResourceSummary")) { - LLHTTPClient::get(mContent["ScriptResourceSummary"], new fetchScriptLimitsRegionSummaryResponder(mInfo)); + LLHTTPClient::get(content["ScriptResourceSummary"], new fetchScriptLimitsRegionSummaryResponder(mInfo)); } } -void fetchScriptLimitsRegionInfoResponder::httpFailure(void) +void fetchScriptLimitsRegionInfoResponder::httpFailure() { - llwarns << "fetchScriptLimitsRegionInfoResponder error [status:" << mStatus << "]: " << mReason << llendl; + llwarns << dumpResponse() << LL_ENDL; } -void fetchScriptLimitsRegionSummaryResponder::httpSuccess(void) +void fetchScriptLimitsRegionSummaryResponder::httpSuccess() { + const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES LLSD fake_content; @@ -265,10 +272,16 @@ void fetchScriptLimitsRegionSummaryResponder::httpSuccess(void) #else - const LLSD& content = mContent; + const LLSD& content = content_ref; #endif + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } + #ifdef DUMP_REPLIES_TO_LLINFOS @@ -309,13 +322,14 @@ void fetchScriptLimitsRegionSummaryResponder::httpSuccess(void) } } -void fetchScriptLimitsRegionSummaryResponder::httpFailure(void) +void fetchScriptLimitsRegionSummaryResponder::httpFailure() { - llwarns << "fetchScriptLimitsRegionSummaryResponder error [status:" << mStatus << "]: " << mReason << llendl; + llwarns << dumpResponse() << LL_ENDL; } -void fetchScriptLimitsRegionDetailsResponder::httpSuccess(void) +void fetchScriptLimitsRegionDetailsResponder::httpSuccess() { + const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES /* Updated detail service, ** denotes field added: @@ -374,10 +388,16 @@ result (map) #else - const LLSD& content = mContent; + const LLSD& content = content_ref; #endif + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } + #ifdef DUMP_REPLIES_TO_LLINFOS LLSDNotationStreamer notation_streamer(content); @@ -418,13 +438,14 @@ result (map) } } -void fetchScriptLimitsRegionDetailsResponder::httpFailure(void) +void fetchScriptLimitsRegionDetailsResponder::httpFailure() { - llwarns << "fetchScriptLimitsRegionDetailsResponder error [status:" << mStatus << "]: " << mReason << llendl; + llwarns << dumpResponse() << LL_ENDL; } -void fetchScriptLimitsAttachmentInfoResponder::httpSuccess(void) +void fetchScriptLimitsAttachmentInfoResponder::httpSuccess() { + const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES @@ -456,16 +477,22 @@ void fetchScriptLimitsAttachmentInfoResponder::httpSuccess(void) summary["used"] = used; fake_content["summary"] = summary; - fake_content["attachments"] = mContent["attachments"]; + fake_content["attachments"] = content_ref["attachments"]; const LLSD& content = fake_content; #else - const LLSD& content = mContent; + const LLSD& content = content_ref; #endif + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } + #ifdef DUMP_REPLIES_TO_LLINFOS LLSDNotationStreamer notation_streamer(content); @@ -514,9 +541,9 @@ void fetchScriptLimitsAttachmentInfoResponder::httpSuccess(void) } } -void fetchScriptLimitsAttachmentInfoResponder::httpFailure(void) +void fetchScriptLimitsAttachmentInfoResponder::httpFailure() { - llwarns << "fetchScriptLimitsAttachmentInfoResponder error [status:" << mStatus << "]: " << mReason << llendl; + llwarns << dumpResponse() << LL_ENDL; } ///---------------------------------------------------------------------------- @@ -604,7 +631,7 @@ void LLPanelScriptLimitsRegionMemory::onNameCache( } std::string name; - LLAvatarNameCache::getPNSName(id, name); + LLAvatarNameCache::getNSName(id, name); std::vector::iterator id_itor; for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor) @@ -706,7 +733,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) } else { - name_is_cached = LLAvatarNameCache::getPNSName(owner_id, owner_buf); // username + name_is_cached = LLAvatarNameCache::getNSName(owner_id, owner_buf); // username } if(!name_is_cached) { @@ -720,30 +747,39 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) } } - LLSD item_params; - item_params["id"] = task_id; + LLScrollListItem::Params item_params; + item_params.value = task_id; - item_params["columns"][0]["column"] = "size"; - item_params["columns"][0]["value"] = size; + LLScrollListCell::Params cell_params; + //cell_params.font = LLFontGL::getFontSansSerif(); - item_params["columns"][1]["column"] = "urls"; - item_params["columns"][1]["value"] = urls; + cell_params.column = "size"; + cell_params.value = size; + item_params.columns.add(cell_params); - item_params["columns"][2]["column"] = "name"; - item_params["columns"][2]["value"] = name_buf; + cell_params.column = "urls"; + cell_params.value = urls; + item_params.columns.add(cell_params); - item_params["columns"][3]["column"] = "owner"; - item_params["columns"][3]["value"] = owner_buf; + cell_params.column = "name"; + cell_params.value = name_buf; + item_params.columns.add(cell_params); - item_params["columns"][4]["column"] = "parcel"; - item_params["columns"][4]["value"] = parcel_name; + cell_params.column = "owner"; + cell_params.value = owner_buf; + item_params.columns.add(cell_params); - item_params["columns"][5]["column"] = "location"; - item_params["columns"][5]["value"] = has_locations + cell_params.column = "parcel"; + cell_params.value = parcel_name; + item_params.columns.add(cell_params); + + cell_params.column = "location"; + cell_params.value = has_locations ? llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z) : ""; + item_params.columns.add(cell_params); - list->addElement(item_params); + list->addRow(item_params); LLSD element; element["owner_id"] = owner_id; @@ -878,13 +914,17 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() } LLParcel* parcel = instance->getCurrentSelectedParcel(); LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); - if (!parcel) //Pretend we have the parcel we're on selected. + + LLUUID current_region_id = gAgent.getRegion()->getRegionID(); + + // Fall back to the parcel we're on if none is selected. + // Fixes parcel script info intermittently working and broken in toolbar button. + if (!parcel) { parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); region = gAgent.getRegion(); } - - LLUUID current_region_id = gAgent.getRegion()->getRegionID(); + // if ((region) && (parcel)) { @@ -921,7 +961,7 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() { llwarns << "Can't get parcel info for script information request" << region_id << ". Region: " << region->getName() - << " does not support RemoteParcelRequest" << llendl; + << " does not support RemoteParcelRequest" << LL_ENDL; std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); getChild("loading_text")->setValue(LLSD(msg_waiting)); diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 1acafb160..524763f98 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -537,7 +537,7 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id, // Already recorded this change? Weird. llinfos << "Received duplicate change for " << " role: " << role_id << " member " << member_id - << " change " << (rmc == RMC_ADD ? "ADD" : "REMOVE") << llendl; + << " change " << (rmc == RMC_ADD ? "ADD" : "REMOVE") << LL_ENDL; } else { @@ -783,9 +783,12 @@ void LLGroupMgrGroupData::sendRoleChanges() break; } case RC_UPDATE_ALL: + // fall through case RC_UPDATE_POWERS: need_power_recalc = true; + // fall through case RC_UPDATE_DATA: + // fall through default: { LLGroupRoleData* group_role_data = (*role_it).second; @@ -1201,6 +1204,8 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data) name = LLTrans::getString("group_role_owners"); } + + lldebugs << "Adding role data: " << name << " {" << role_id << "}" << llendl; LLGroupRoleData* rd = new LLGroupRoleData(role_id,name,title,desc,powers,member_count); group_datap->mRoles[role_id] = rd; @@ -1474,7 +1479,7 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data) } else { - // *TODO:translate + // *TODO: Translate LLSD args; args["MESSAGE"] = message; LLNotificationsUtil::add("UnableToCreateGroup", args); @@ -1617,6 +1622,7 @@ void LLGroupMgr::sendGroupMembersRequest(const LLUUID& group_id) } } + void LLGroupMgr::sendGroupRoleDataRequest(const LLUUID& group_id) { lldebugs << "LLGroupMgr::sendGroupRoleDataRequest" << llendl; @@ -1652,7 +1658,7 @@ void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id) // *TODO: KLW FIXME: Should we start a member or role data request? llinfos << " Pending: " << (group_datap->mPendingRoleMemberRequest ? "Y" : "N") << " MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N") - << " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << llendl; + << " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL; group_datap->mPendingRoleMemberRequest = TRUE; return; } @@ -1885,8 +1891,6 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, bool start_message = true; LLMessageSystem* msg = gMessageSystem; - - LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); if (!group_datap) return; @@ -1952,10 +1956,6 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, } -class AIHTTPTimeoutPolicy; -extern AIHTTPTimeoutPolicy groupBanDataResponder_timeout; -extern AIHTTPTimeoutPolicy groupMemberDataResponder_timeout; - // Responder class for capability group management class GroupBanDataResponder : public LLHTTPClient::ResponderWithResult { @@ -1964,8 +1964,7 @@ public: virtual ~GroupBanDataResponder() {} virtual void httpSuccess(); virtual void httpFailure(); - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return groupBanDataResponder_timeout; } - /*virtual*/ char const* getName(void) const { return "GroupBanDataResponder"; } + virtual char const* getName() const { return "GroupBanDataResponder"; } private: LLUUID mGroupID; BOOL mForceRefresh; @@ -1984,18 +1983,14 @@ void GroupBanDataResponder::httpFailure() void GroupBanDataResponder::httpSuccess() { - if (mContent.size()) + if (mContent.has("ban_list")) { - if (mContent.has("ban_list")) - { - // group ban data received - LLGroupMgr::processGroupBanRequest(mContent); - mForceRefresh = false; - } + // group ban data received + LLGroupMgr::processGroupBanRequest(mContent); } - if (mForceRefresh) + else if (mForceRefresh) { - // no ban data received, refreshing data successful operation + // no ban data received, refreshing data after successful operation LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_GET, mGroupID); } } @@ -2097,25 +2092,34 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) // Responder class for capability group management class GroupMemberDataResponder : public LLHTTPClient::ResponderWithResult { + LOG_CLASS(GroupMemberDataResponder); public: GroupMemberDataResponder() {} virtual ~GroupMemberDataResponder() {} - /*virtual*/ void httpSuccess(void); - /*virtual*/ void httpFailure(void); - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return groupMemberDataResponder_timeout; } - /*virtual*/ char const* getName(void) const { return "GroupMemberDataResponder"; } + private: + /* virtual */ void httpSuccess(); + /* virtual */ void httpFailure(); + /* virtual */ char const* getName() const { return "GroupMemberDataResponder"; } + LLSD mMemberData; }; -void GroupMemberDataResponder::httpFailure(void) +void GroupMemberDataResponder::httpFailure() { - LL_WARNS("GrpMgr") << "Error receiving group member data." << LL_ENDL; + LL_WARNS("GrpMgr") << "Error receiving group member data " + << dumpResponse() << LL_ENDL; } -void GroupMemberDataResponder::httpSuccess(void) +void GroupMemberDataResponder::httpSuccess() { - LLGroupMgr::processCapGroupMembersRequest(mContent); + const LLSD& content = getContent(); + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } + LLGroupMgr::processCapGroupMembersRequest(content); } @@ -2164,6 +2168,7 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) mLastGroupMembersRequestFrame = gFrameCount; } + // static void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) { @@ -2274,10 +2279,12 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) // I'm going to be dumb and just call services I most likely don't need // with the thought being that the system might need it to be done. // - // TODO: Refactor to reduce multiple calls for data we already have. + // TODO: + // Refactor to reduce multiple calls for data we already have. if (group_datap->mTitles.size() < 1) LLGroupMgr::getInstance()->sendGroupTitlesRequest(group_id); + group_datap->mMemberDataComplete = true; group_datap->mMemberRequestID.setNull(); // Make the role-member data request @@ -2289,8 +2296,10 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) group_datap->mChanged = TRUE; LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA); + } + void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id) { lldebugs << "LLGroupMgr::sendGroupRoleChanges" << llendl; diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index bf40bbcaa..20c637112 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -49,6 +49,8 @@ enum LLGroupChange GC_ALL }; +const U32 GB_MAX_BANNED_AGENTS = 500; + class LLGroupMgrObserver { public: @@ -262,7 +264,7 @@ public: const LLUUID& getMemberVersion() const { return mMemberVersion; } void clearBanList() { mBanList.clear(); } - void getBanList(const LLUUID& ban_i, const LLGroupBanData& ban_data = LLGroupBanData()); + void getBanList(const LLUUID& group_id, LLGroupBanData& ban_data); const LLGroupBanData& getBanEntry(const LLUUID& ban_id) { return mBanList[ban_id]; } void createBanEntry(const LLUUID& ban_id, const LLGroupBanData& ban_data = LLGroupBanData()); diff --git a/indra/newview/llhoverview.cpp b/indra/newview/llhoverview.cpp index e35848d78..1e8ecbcc3 100644 --- a/indra/newview/llhoverview.cpp +++ b/indra/newview/llhoverview.cpp @@ -285,7 +285,7 @@ void LLHoverView::updateText() { // [/RLVa:KB] std::string complete_name; - if (!LLAvatarNameCache::getPNSName(hit_object->getID(), complete_name)) + if (!LLAvatarNameCache::getNSName(hit_object->getID(), complete_name)) complete_name = firstname->getString() + std::string(" ") + lastname->getString(); if (title) @@ -408,7 +408,7 @@ void LLHoverView::updateText() { line.append(LLTrans::getString("TooltipPublic")); } - else if(LLAvatarNameCache::getPNSName(owner, name)) + else if (LLAvatarNameCache::getNSName(owner, name)) { // [RLVa:KB] - Checked: 2009-07-08 (RLVa-1.0.0e) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index d653c8283..3efb9299a 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -550,7 +550,7 @@ void LLHUDEffectLookAt::render() static const LLCachedControl lookAtNames("LookAtNameSystem"); if (lookAtNames < 0) return; std::string text; - if (!LLAvatarNameCache::getPNSName(static_cast(mSourceObject.get())->getID(), text, lookAtNames)) return; + if (!LLAvatarNameCache::getNSName(static_cast(mSourceObject.get())->getID(), text, lookAtNames)) return; if (text.length() > 9 && 0 == text.compare(text.length() - 9, 9, " Resident")) text.erase(text.length() - 9); LLVector3 offset = gAgentCamera.getCameraPositionAgent() - target; diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index ccc13b61c..cd2660068 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -401,11 +401,9 @@ LLFloaterIMPanel::LLFloaterIMPanel( void LLFloaterIMPanel::onAvatarNameLookup(const LLAvatarName& avatar_name) { - std::string title; - LLAvatarNameCache::getPNSName(avatar_name, title); - setTitle(title); + setTitle(avatar_name.getNSName()); const S32& ns(gSavedSettings.getS32("IMNameSystem")); - LLAvatarNameCache::getPNSName(avatar_name, title, ns); + std::string title(avatar_name.getNSName(ns)); if (!ns || ns == 3) // Remove Resident, if applicable. { size_t pos(title.find(" Resident")); @@ -768,7 +766,7 @@ void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incol static const LLCachedControl italicize("LiruItalicizeActions"); is_irc = italicize && utf8msg[0] != ':'; if (source.notNull()) - LLAvatarNameCache::getPNSName(source, show_name); + LLAvatarNameCache::getNSName(source, show_name); // Convert the name to a hotlink and add to message. LLStyleSP source_style = LLStyleMap::instance().lookupAgent(source); source_style->mItalic = is_irc; @@ -1434,7 +1432,7 @@ void LLFloaterIMPanel::processIMTyping(const LLIMInfo* im_info, bool typing) { // other user started typing std::string name; - if (!LLAvatarNameCache::getPNSName(im_info->mFromID, name)) name = im_info->mName; + if (!LLAvatarNameCache::getNSName(im_info->mFromID, name)) name = im_info->mName; addTypingIndicator(name); } else diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index ac24627c5..1d54afe05 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -1091,7 +1091,7 @@ void LLIMMgr::noteOfflineUsers( std::string full_name; if (info && !info->isOnline() - && LLAvatarNameCache::getPNSName(ids.get(i), full_name)) + && LLAvatarNameCache::getNSName(ids.get(i), full_name)) { LLUIString offline = LLTrans::getString("offline_message"); offline.setArg("[NAME]", full_name); diff --git a/indra/newview/llmenucommands.cpp b/indra/newview/llmenucommands.cpp index 6183c6942..393efcc1e 100644 --- a/indra/newview/llmenucommands.cpp +++ b/indra/newview/llmenucommands.cpp @@ -182,7 +182,6 @@ struct MenuFloaterDict : public LLSingleton registerFloater("DayCycle", boost::bind(LLFloaterDayCycle::show), boost::bind(LLFloaterDayCycle::isOpen)); registerFloater("debug avatar", boost::bind(handle_debug_avatar_textures, (void*)NULL)); registerFloater("debug settings", boost::bind(handle_singleton_toggle, (void*)NULL)); - registerFloater("displayname", boost::bind(LLFloaterDisplayName::show)); registerFloater("edit ui", boost::bind(LLFloaterEditUI::show, (void*)NULL)); registerFloater("EnvSettings", boost::bind(LLFloaterEnvSettings::show), boost::bind(LLFloaterEnvSettings::isOpen)); registerFloater("fly", boost::bind(LLAgent::toggleFlying)); @@ -229,6 +228,7 @@ struct MenuFloaterDict : public LLSingleton registerFloater ("chat history"); registerFloater ("communicate"); registerFloater ("destinations"); + registerFloater ("displayname"); registerFloater ("friends", 0); registerFloater ("gestures"); registerFloater ("groups", 1); diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index 2e34271a1..6536ed2c8 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -189,7 +189,7 @@ LLScrollListItem* LLNameListCtrl::addNameItemRow( } else if (LLAvatarNameCache::get(id, &av_name)) { - LLAvatarNameCache::getPNSName(av_name, fullname, mNameSystem); + fullname = av_name.getNSName(mNameSystem); } else { @@ -287,7 +287,7 @@ void LLNameListCtrl::onAvatarNameCache(const LLUUID& agent_id, } std::string name; - LLAvatarNameCache::getPNSName(av_name, name, mNameSystem); + name = av_name.getNSName(mNameSystem); // Append optional suffix. if (!suffix.empty()) diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 93b204759..4d66276dd 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -952,7 +952,7 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& tool_tip, LLRect* stick LLVector3d targetPosition = (*current).second; std::string fullName; - if (targetUUID.notNull() && LLAvatarNameCache::getPNSName(targetUUID, fullName)) + if (targetUUID.notNull() && LLAvatarNameCache::getNSName(targetUUID, fullName)) { //tool_tip.append(fullName); // [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index f8cecab8c..ac43b5dac 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -98,10 +98,10 @@ void LLPanelAvatarTab::setAvatarID(const LLUUID& avatar_id) { if(mAvatarID != avatar_id) { - if(mAvatarID.notNull()) + if (mAvatarID.notNull()) LLAvatarPropertiesProcessor::getInstance()->removeObserver(mAvatarID, this); mAvatarID = avatar_id; - if(mAvatarID.notNull()) + if (mAvatarID.notNull()) LLAvatarPropertiesProcessor::getInstance()->addObserver(mAvatarID, this); } @@ -132,20 +132,19 @@ LLPanelAvatarSecondLife::LLPanelAvatarSecondLife(const std::string& name, { } -void LLPanelAvatarSecondLife::refresh() +LLPanelAvatarSecondLife::~LLPanelAvatarSecondLife() { - updatePartnerName(); + mCacheConnection.disconnect(); } -void LLPanelAvatarSecondLife::updatePartnerName() +void LLPanelAvatarSecondLife::refresh() { - if (mPartnerID.notNull()) - { - std::string name; - if (LLAvatarNameCache::getPNSName(mPartnerID, name)) - childSetTextArg("partner_edit", "[NAME]", name); - childSetEnabled("partner_info", TRUE); - } +} + +void LLPanelAvatarSecondLife::updatePartnerName(const LLAvatarName& name) +{ + mCacheConnection.disconnect(); + childSetTextArg("partner_edit", "[NAME]", name.getNSName()); } //----------------------------------------------------------------------------- @@ -206,7 +205,12 @@ void LLPanelAvatarSecondLife::processProperties(void* data, EAvatarProcessorType childSetValue("allow_publish", allow_publish); setPartnerID(pAvatarData->partner_id); - updatePartnerName(); + if (mPartnerID.notNull()) + { + mCacheConnection.disconnect(); + mCacheConnection = LLAvatarNameCache::get(mPartnerID, boost::bind(&LLPanelAvatarSecondLife::updatePartnerName, this, _2)); + childSetEnabled("partner_info", TRUE); + } } } else if(type == APT_GROUPS) @@ -214,12 +218,8 @@ void LLPanelAvatarSecondLife::processProperties(void* data, EAvatarProcessorType const LLAvatarGroups* pAvatarGroups = static_cast( data ); if(pAvatarGroups && pAvatarGroups->avatar_id == mAvatarID && pAvatarGroups->avatar_id.notNull()) { - LLScrollListCtrl* group_list = getChild("groups"); -// if(group_list) -// { -// group_list->deleteAllItems(); -// } - if (0 == pAvatarGroups->group_list.size()) + LLScrollListCtrl* group_list = getChild("groups"); + if (!pAvatarGroups->group_list.size()) { group_list->setCommentText(getString("None")); } @@ -298,12 +298,9 @@ void LLPanelAvatarSecondLife::enableControls(BOOL self) childSetEnabled("?", self); } -// static -void LLPanelAvatarFirstLife::onClickImage(void* data) +void LLPanelAvatarFirstLife::onClickImage() { - LLPanelAvatarFirstLife* self = (LLPanelAvatarFirstLife*)data; - - LLTextureCtrl* image_ctrl = self->getChild("img"); + LLTextureCtrl* image_ctrl = getChild("img"); if(image_ctrl) { LLUUID mUUID = image_ctrl->getImageAssetID(); @@ -342,16 +339,14 @@ void LLPanelAvatarFirstLife::processProperties(void* data, EAvatarProcessorType } } -// static -void LLPanelAvatarSecondLife::onClickImage(void* data) +void LLPanelAvatarSecondLife::onClickImage() { - LLPanelAvatarSecondLife* self = (LLPanelAvatarSecondLife*)data; - LLNameEditor* name_ctrl = self->getChild("dnname"); + LLNameEditor* name_ctrl = getChild("dnname"); if(name_ctrl) { std::string name_text = name_ctrl->getText(); - LLTextureCtrl* image_ctrl = self->getChild("img"); + LLTextureCtrl* image_ctrl = getChild("img"); if(image_ctrl) { LLUUID mUUID = image_ctrl->getImageAssetID(); @@ -384,52 +379,20 @@ void LLPanelAvatarSecondLife::onClickImage(void* data) } -// static -void LLPanelAvatarSecondLife::onDoubleClickGroup(void* data) +void LLPanelAvatarSecondLife::onDoubleClickGroup() { - LLPanelAvatarSecondLife* self = (LLPanelAvatarSecondLife*)data; - - LLScrollListCtrl* group_list = self->getChild("groups"); - if(group_list) - { - LLScrollListItem* item = group_list->getFirstSelected(); - if (item) - { - LLGroupActions::show(item->getUUID()); - } - } -} - -// static -void LLPanelAvatarSecondLife::onClickPublishHelp(void *) -{ - LLNotificationsUtil::add("ClickPublishHelpAvatar"); -} - -// static -void LLPanelAvatarSecondLife::onClickPartnerHelp(void *) -{ - LLNotificationsUtil::add("ClickPartnerHelpAvatar", LLSD(), LLSD(), onClickPartnerHelpLoadURL); + if (LLScrollListItem* item = getChild("groups")->getFirstSelected()) + LLGroupActions::show(item->getUUID()); } // static bool LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); - if (option == 0) - { + if (!LLNotification::getSelectedOption(notification, response)) LLWeb::loadURL("http://secondlife.com/partner"); - } return false; } -// static -void LLPanelAvatarSecondLife::onClickPartnerInfo(void *data) -{ - LLPanelAvatarSecondLife* self = (LLPanelAvatarSecondLife*) data; - LLAvatarActions::showProfile(self->mPartnerID); -} - //----------------------------------------------------------------------------- // LLPanelAvatarFirstLife() //----------------------------------------------------------------------------- @@ -450,15 +413,16 @@ void LLPanelAvatarFirstLife::enableControls(BOOL self) // postBuild //----------------------------------------------------------------------------- -BOOL LLPanelAvatarSecondLife::postBuild(void) +static void show_partner_help() { LLNotificationsUtil::add("ClickPartnerHelpAvatar", LLSD(), LLSD(), boost::bind(LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL, _1, _2)); } +BOOL LLPanelAvatarSecondLife::postBuild() { childSetEnabled("born", FALSE); childSetEnabled("partner_edit", FALSE); - childSetAction("partner_help",onClickPartnerHelp,this); - childSetAction("partner_info", onClickPartnerInfo, this); + getChild("partner_help")->setCommitCallback(boost::bind(show_partner_help)); + getChild("partner_info")->setCommitCallback(boost::bind(LLAvatarActions::showProfile, boost::ref(mPartnerID), false)); childSetEnabled("partner_info", mPartnerID.notNull()); - childSetAction("?",onClickPublishHelp,this); + childSetAction("?", boost::bind(LLNotificationsUtil::add, "ClickPublishHelpAvatar")); LLPanelAvatar* pa = getPanelAvatar(); enableControls(pa->getAvatarID() == gAgentID); @@ -477,31 +441,35 @@ BOOL LLPanelAvatarSecondLife::postBuild(void) getChild("Add Friend...")->setCommitCallback(boost::bind(LLAvatarActions::requestFriendshipDialog, boost::bind(&LLPanelAvatar::getAvatarID, pa))); getChild("Pay...")->setCommitCallback(boost::bind(LLAvatarActions::pay, boost::bind(&LLPanelAvatar::getAvatarID, pa))); - getChild("Mute")->setCommitCallback(boost::bind(LLAvatarActions::toggleBlock, boost::bind(&LLPanelAvatar::getAvatarID, pa))); + if (LLUICtrl* ctrl = findChild("Mute")) + { + ctrl->setCommitCallback(boost::bind(LLAvatarActions::toggleBlock, boost::bind(&LLPanelAvatar::getAvatarID, pa))); + ctrl->setValue(LLMuteList::instance().isMuted(mAvatarID)); + } getChild("Offer Teleport...")->setCommitCallback(boost::bind(static_cast(LLAvatarActions::offerTeleport), boost::bind(&LLPanelAvatar::getAvatarID, pa))); getChild("groups")->setDoubleClickCallback(boost::bind(&LLPanelAvatarSecondLife::onDoubleClickGroup,this)); - childSetAction("bigimg", onClickImage, this); + getChild("bigimg")->setCommitCallback(boost::bind(&LLPanelAvatarSecondLife::onClickImage, this)); getChild("img")->setFallbackImageName("default_profile_picture.j2c"); return TRUE; } -BOOL LLPanelAvatarFirstLife::postBuild(void) +BOOL LLPanelAvatarFirstLife::postBuild() { BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() ); enableControls(own_avatar); getChild("img")->setFallbackImageName("default_profile_picture.j2c"); - childSetAction("flbigimg", onClickImage, this); + getChild("flbigimg")->setCommitCallback(boost::bind(&LLPanelAvatarFirstLife::onClickImage, this)); return TRUE; } -BOOL LLPanelAvatarNotes::postBuild(void) +BOOL LLPanelAvatarNotes::postBuild() { getChild("notes edit")->setCommitCallback(boost::bind(&LLPanelAvatar::sendAvatarNotesUpdate, getPanelAvatar())); @@ -510,22 +478,21 @@ BOOL LLPanelAvatarNotes::postBuild(void) return TRUE; } -BOOL LLPanelAvatarWeb::postBuild(void) +BOOL LLPanelAvatarWeb::postBuild() { LLLineEditor* url_edit = getChild("url_edit"); - url_edit->setKeystrokeCallback(boost::bind(&LLPanelAvatarWeb::onURLKeystroke,this,_1)); - url_edit->setCommitCallback(boost::bind(&LLPanelAvatarWeb::onCommitURL,this,_2)); + LLUICtrl* loadctrl = getChild("load"); - getChild("load")->setCommitCallback(boost::bind(&LLPanelAvatarWeb::onCommitLoad, this, _2)); + url_edit->setKeystrokeCallback(boost::bind(&LLView::setEnabled, loadctrl, boost::bind(&std::string::length, boost::bind(&LLLineEditor::getText, _1)))); + url_edit->setCommitCallback(boost::bind(&LLPanelAvatarWeb::load, this, boost::bind(&LLSD::asString, _2))); - childSetAction("web_profile_help",onClickWebProfileHelp,this); + loadctrl->setCommitCallback(boost::bind(&LLPanelAvatarWeb::onCommitLoad, this, _2)); + + getChild("web_profile_help")->setCommitCallback(boost::bind(LLNotificationsUtil::add, "ClickWebProfileHelpAvatar")); mWebBrowser = getChild("profile_html"); mWebBrowser->addObserver(this); - // links open in internally - //mWebBrowser->setOpenInExternalBrowser( false ); - return TRUE; } @@ -542,21 +509,27 @@ void LLPanelAvatarWeb::processProperties(void* data, EAvatarProcessorType type) } } -BOOL LLPanelAvatarClassified::postBuild(void) +BOOL LLPanelAvatarClassified::postBuild() { - childSetAction("New...",onClickNew,this); - childSetAction("Delete...",onClickDelete,this); + getChild("New...")->setCommitCallback(boost::bind(&LLPanelAvatarClassified::onClickNew, this)); + getChild("Delete...")->setCommitCallback(boost::bind(&LLPanelAvatarClassified::onClickDelete, this)); + // *HACK: Don't allow making new classifieds from inside the directory. + // The logic for save/don't save when closing is too hairy, and the + // directory is conceptually read-only. JC + for (LLView* view = this; !mInDirectory && view; view = view->getParent()) + if (view->getName() == "directory") + mInDirectory = true; return TRUE; } -BOOL LLPanelAvatarPicks::postBuild(void) +BOOL LLPanelAvatarPicks::postBuild() { - childSetAction("New...",onClickNew,this); - childSetAction("Delete...",onClickDelete,this); + getChild("New...")->setCommitCallback(boost::bind(&LLPanelAvatarPicks::onClickNew, this)); + getChild("Delete...")->setCommitCallback(boost::bind(&LLPanelAvatarPicks::onClickDelete, this)); //For pick import and export - RK - childSetAction("Import...",onClickImport,this); - childSetAction("Export...",onClickExport,this); + getChild("Import...")->setCommitCallback(boost::bind(&LLPanelAvatarPicks::onClickImport, this)); + getChild("Export...")->setCommitCallback(boost::bind(&LLPanelAvatarPicks::onClickExport, this)); return TRUE; } @@ -618,15 +591,15 @@ LLPanelAvatarWeb::~LLPanelAvatarWeb() if ( mWebBrowser ) { mWebBrowser->remObserver( this ); - }; + } } void LLPanelAvatarWeb::refresh() { - if (mNavigateTo != "") + if (!mNavigateTo.empty()) { llinfos << "Loading " << mNavigateTo << llendl; - mWebBrowser->navigateTo( mNavigateTo ); + mWebBrowser->navigateTo(mNavigateTo); mNavigateTo = ""; } } @@ -644,13 +617,11 @@ void LLPanelAvatarWeb::setWebURL(std::string url) bool changed_url = (mHome != url); mHome = url; - bool have_url = !mHome.empty(); childSetText("url_edit", mHome); childSetEnabled("load", mHome.length() > 0); - if (have_url - && gSavedSettings.getBOOL("AutoLoadWebProfiles")) + if (!mHome.empty() && gSavedSettings.getBOOL("AutoLoadWebProfiles")) { if (changed_url) { @@ -659,30 +630,16 @@ void LLPanelAvatarWeb::setWebURL(std::string url) } else { - childSetVisible("profile_html",false); + childSetVisible("profile_html", false); childSetVisible("status_text", false); } - BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() ); - childSetVisible("status_text",!own_avatar && !mHome.empty()); + childSetVisible("status_text", !mHome.empty() && getPanelAvatar()->getAvatarID() != gAgentID); } - -void LLPanelAvatarWeb::onCommitURL(const LLSD& value) -{ - load(value.asString()); -} - -// static -void LLPanelAvatarWeb::onClickWebProfileHelp(void *) -{ - LLNotificationsUtil::add("ClickWebProfileHelpAvatar"); -} - -void LLPanelAvatarWeb::load(std::string url) +void LLPanelAvatarWeb::load(const std::string& url) { bool have_url = (!url.empty()); - childSetVisible("profile_html", have_url); childSetVisible("status_text", have_url); childSetText("status_text", LLStringUtil::null); @@ -693,34 +650,21 @@ void LLPanelAvatarWeb::load(std::string url) } } -void LLPanelAvatarWeb::onURLKeystroke(LLLineEditor* editor) -{ - LLSD::String url = editor->getText(); - childSetEnabled("load", url.length() > 0); - return; -} - void LLPanelAvatarWeb::onCommitLoad(const LLSD& value) { - LLSD::String valstr = value.asString(); - LLSD::String urlstr = childGetText("url_edit"); - if (valstr == "") // load url string into browser panel + const std::string& valstr(value.asString()); + if (valstr.empty()) // load url string into browser panel { - load(urlstr); + load(childGetText("url_edit")); } else if (valstr == "open") // open in user's external browser { - if (!urlstr.empty()) - { - LLWeb::loadURLExternal(urlstr); - } + const std::string& urlstr(childGetText("url_edit")); + if (!urlstr.empty()) LLWeb::loadURLExternal(urlstr); } else if (valstr == "home") // reload profile owner's home page { - if (!mHome.empty()) - { - load(mHome); - } + if (!mHome.empty()) load(mHome); } } @@ -731,13 +675,13 @@ void LLPanelAvatarWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent ev switch(event) { case MEDIA_EVENT_STATUS_TEXT_CHANGED: - childSetText("status_text", self->getStatusText() ); + childSetText("status_text", self->getStatusText()); break; - + case MEDIA_EVENT_LOCATION_CHANGED: - childSetText("url_edit", self->getLocation() ); + childSetText("url_edit", self->getLocation()); break; - + default: // Having a default case makes the compiler happy. break; @@ -861,45 +805,12 @@ void LLPanelAvatarNotes::clearControls() LLPanelAvatarClassified::LLPanelAvatarClassified(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar) : LLPanelAvatarTab(name, rect, panel_avatar) +, mInDirectory(false) { } - void LLPanelAvatarClassified::refresh() { - BOOL self = (gAgent.getID() == getPanelAvatar()->getAvatarID()); - - LLTabContainer* tabs = getChild("classified tab"); - - S32 tab_count = tabs ? tabs->getTabCount() : 0; - - bool allow_new = tab_count < MAX_CLASSIFIEDS; -// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) - allow_new &= !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); -// [/RLVa:KB] - bool allow_delete = (tab_count > 0); - bool show_help = (tab_count == 0); - - // *HACK: Don't allow making new classifieds from inside the directory. - // The logic for save/don't save when closing is too hairy, and the - // directory is conceptually read-only. JC - bool in_directory = false; - LLView* view = this; - while (view) - { - if (view->getName() == "directory") - { - in_directory = true; - break; - } - view = view->getParent(); - } - childSetEnabled("New...", self && !in_directory && allow_new); - childSetVisible("New...", !in_directory); - childSetEnabled("Delete...", self && !in_directory && allow_delete); - childSetVisible("Delete...", !in_directory); - childSetVisible("classified tab",!show_help); - if (!isDataRequested()) { LLAvatarPropertiesProcessor::getInstance()->sendAvatarClassifiedsRequest(mAvatarID); @@ -924,19 +835,10 @@ BOOL LLPanelAvatarClassified::canClose() BOOL LLPanelAvatarClassified::titleIsValid() { - LLTabContainer* tabs = getChild("classified tab"); - if ( tabs ) - { - LLPanelClassifiedInfo* panel = (LLPanelClassifiedInfo*)tabs->getCurrentPanel(); - if ( panel ) - { - if ( ! panel->titleIsValid() ) - { + if (LLTabContainer* tabs = getChild("classified tab")) + if (LLPanelClassifiedInfo* panel = (LLPanelClassifiedInfo*)tabs->getCurrentPanel()) + if (!panel->titleIsValid()) return FALSE; - }; - }; - }; - return TRUE; } @@ -953,12 +855,7 @@ void LLPanelAvatarClassified::apply() void LLPanelAvatarClassified::deleteClassifiedPanels() { - LLTabContainer* tabs = getChild("classified tab"); - if (tabs) - { - tabs->deleteAllTabs(); - } - + getChild("classified tab")->deleteAllTabs(); childSetVisible("New...", false); childSetVisible("Delete...", false); childSetVisible("loading_text", true); @@ -967,10 +864,10 @@ void LLPanelAvatarClassified::deleteClassifiedPanels() // virtual void LLPanelAvatarClassified::processProperties(void* data, EAvatarProcessorType type) { - if(type == APT_CLASSIFIEDS) + if (type == APT_CLASSIFIEDS) { LLAvatarClassifieds* c_info = static_cast(data); - if(c_info && mAvatarID == c_info->target_id) + if (c_info && mAvatarID == c_info->target_id) { LLTabContainer* tabs = getChild("classified tab"); @@ -985,21 +882,24 @@ void LLPanelAvatarClassified::processProperties(void* data, EAvatarProcessorType panel_classified->markForServerRequest(); // The button should automatically truncate long names for us - if(tabs) - { - tabs->addTabPanel(panel_classified, it->name); - } + tabs->addTabPanel(panel_classified, it->name); } // Make sure somebody is highlighted. This works even if there // are no tabs in the container. - if(tabs) - { - tabs->selectFirstTab(); - } + tabs->selectFirstTab(); - childSetVisible("New...", true); - childSetVisible("Delete...", true); + bool self = gAgentID == mAvatarID; + S32 tab_count = tabs->getTabCount(); + bool allow_new = tab_count < MAX_CLASSIFIEDS +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) + && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); +// [/RLVa:KB] + childSetEnabled("New...", self && !mInDirectory && allow_new); + childSetVisible("New...", !mInDirectory); + childSetEnabled("Delete...", self && !mInDirectory && tab_count); + childSetVisible("Delete...", !mInDirectory); + childSetVisible("classified tab", !tab_count); childSetVisible("loading_text", false); } } @@ -1008,82 +908,63 @@ void LLPanelAvatarClassified::processProperties(void* data, EAvatarProcessorType // Create a new classified panel. It will automatically handle generating // its own id when it's time to save. // static -void LLPanelAvatarClassified::onClickNew(void* data) +void LLPanelAvatarClassified::onClickNew() { // [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) - if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) - { - return; - } + if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) return; // [/RLVa:KB] - LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - - LLNotificationsUtil::add("AddClassified", LLSD(), LLSD(), boost::bind(&LLPanelAvatarClassified::callbackNew, self, _1, _2)); + LLNotificationsUtil::add("AddClassified", LLSD(), LLSD(), boost::bind(&LLPanelAvatarClassified::callbackNew, this, _1, _2)); } bool LLPanelAvatarClassified::callbackNew(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); - if (0 == option) - { - LLPanelClassifiedInfo* panel_classified = new LLPanelClassifiedInfo(false, false); - panel_classified->initNewClassified(); - LLTabContainer* tabs = getChild("classified tab"); - if(tabs) - { - tabs->addTabPanel(panel_classified, panel_classified->getClassifiedName()); - tabs->selectLastTab(); - } - } - return false; + if (option) return false; + LLPanelClassifiedInfo* panel_classified = new LLPanelClassifiedInfo(false, false); + panel_classified->initNewClassified(); + LLTabContainer* tabs = getChild("classified tab"); + tabs->addTabPanel(panel_classified, panel_classified->getClassifiedName()); + tabs->selectLastTab(); + bool allow_new = tabs->getTabCount() < MAX_CLASSIFIEDS +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) + && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC); +// [/RLVa:KB] + childSetEnabled("New...", allow_new); + childSetEnabled("Delete...", true); + return true; } // static -void LLPanelAvatarClassified::onClickDelete(void* data) +void LLPanelAvatarClassified::onClickDelete() { - LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - - LLTabContainer* tabs = self->getChild("classified tab"); - LLPanelClassifiedInfo* panel_classified = NULL; - if(tabs) - { - panel_classified = (LLPanelClassifiedInfo*)tabs->getCurrentPanel(); - } + LLTabContainer* tabs = getChild("classified tab"); + LLPanelClassifiedInfo* panel_classified = (LLPanelClassifiedInfo*)tabs->getCurrentPanel(); if (!panel_classified) return; LLSD args; args["NAME"] = panel_classified->getClassifiedName(); - LLNotificationsUtil::add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelAvatarClassified::callbackDelete, self, _1, _2)); - + LLNotificationsUtil::add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelAvatarClassified::callbackDelete, this, _1, _2)); } -bool LLPanelAvatarClassified::callbackDelete(const LLSD& notification, const LLSD& response) +bool LLPanelAvatarClassified::callbackDelete(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); + if (option) return false; LLTabContainer* tabs = getChild("classified tab"); - LLPanelClassifiedInfo* panel_classified=NULL; - if(tabs) - { - panel_classified = (LLPanelClassifiedInfo*)tabs->getCurrentPanel(); - } + LLPanelClassifiedInfo* panel_classified = (LLPanelClassifiedInfo*)tabs->getCurrentPanel(); if (!panel_classified) return false; - if (0 == option) - { - LLAvatarPropertiesProcessor::getInstance()->sendClassifiedDelete(panel_classified->getClassifiedID()); - - if(tabs) - { - tabs->removeTabPanel(panel_classified); - } - delete panel_classified; - panel_classified = NULL; - } - return false; + LLAvatarPropertiesProcessor::getInstance()->sendClassifiedDelete(panel_classified->getClassifiedID()); + tabs->removeTabPanel(panel_classified); + delete panel_classified; + panel_classified = NULL; + childSetEnabled("New...", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + childSetEnabled("Delete...", tabs->getTabCount()); + return true; } @@ -1100,22 +981,6 @@ LLPanelAvatarPicks::LLPanelAvatarPicks(const std::string& name, void LLPanelAvatarPicks::refresh() { - BOOL self = (gAgent.getID() == getPanelAvatar()->getAvatarID()); - LLTabContainer* tabs = getChild("picks tab"); - S32 tab_count = tabs ? tabs->getTabCount() : 0; -// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) - childSetEnabled("New...", self && tab_count < MAX_AVATAR_PICKS && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ); -// [/RLVa:KB] - //childSetEnabled("New...", self && tab_count < MAX_AVATAR_PICKS); - childSetEnabled("Delete...", self && tab_count > 0); - childSetVisible("New...", self && getPanelAvatar()->isEditable()); - childSetVisible("Delete...", self && getPanelAvatar()->isEditable()); - - //For pick import/export - RK - childSetVisible("Import...", self && getPanelAvatar()->isEditable()); - childSetEnabled("Export...", self && tab_count > 0); - childSetVisible("Export...", self && getPanelAvatar()->isEditable()); - if (!isDataRequested()) { LLAvatarPropertiesProcessor::getInstance()->sendAvatarPicksRequest(mAvatarID); @@ -1126,11 +991,7 @@ void LLPanelAvatarPicks::refresh() void LLPanelAvatarPicks::deletePickPanels() { - LLTabContainer* tabs = getChild("picks tab"); - if(tabs) - { - tabs->deleteAllTabs(); - } + getChild("picks tab")->deleteAllTabs(); childSetVisible("New...", false); childSetVisible("Delete...", false); @@ -1145,14 +1006,14 @@ void LLPanelAvatarPicks::deletePickPanels() // virtual void LLPanelAvatarPicks::processProperties(void* data, EAvatarProcessorType type) { - if(type == APT_PICKS) + if (type == APT_PICKS) { LLAvatarPicks* picks = static_cast(data); //llassert_always(picks->target_id != gAgent.getID()); //llassert_always(mAvatarID != gAgent.getID()); - if(picks && mAvatarID == picks->target_id) + if (picks && mAvatarID == picks->target_id) { LLTabContainer* tabs = getChild("picks tab"); @@ -1160,7 +1021,8 @@ void LLPanelAvatarPicks::processProperties(void* data, EAvatarProcessorType type // number of new panels. deletePickPanels(); - for(LLAvatarPicks::picks_list_t::iterator it = picks->picks_list.begin(); + bool self(gAgentID == mAvatarID); + for (LLAvatarPicks::picks_list_t::iterator it = picks->picks_list.begin(); it != picks->picks_list.end(); ++it) { LLPanelPick* panel_pick = new LLPanelPick(); @@ -1171,35 +1033,41 @@ void LLPanelAvatarPicks::processProperties(void* data, EAvatarProcessorType type panel_pick->markForServerRequest(); // The button should automatically truncate long names for us - if(tabs) - { - llinfos << "Adding tab for " << mAvatarID << " " << ((mAvatarID == gAgent.getID()) ? "Self" : "Other") << ": '" << it->second << "'" << llendl; - tabs->addTabPanel(panel_pick, it->second); - } + llinfos << "Adding tab for " << mAvatarID << " " << (self ? "Self" : "Other") << ": '" << it->second << "'" << llendl; + tabs->addTabPanel(panel_pick, it->second); } // Make sure somebody is highlighted. This works even if there // are no tabs in the container. - if(tabs) - { - tabs->selectFirstTab(); - } + tabs->selectFirstTab(); + bool edit(getPanelAvatar()->isEditable()); + S32 tab_count = tabs->getTabCount(); + LLView* view = getChildView("New..."); + view->setEnabled(self && tab_count < MAX_AVATAR_PICKS +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) + && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] + view->setVisible(self && edit); + view = getChildView("Delete..."); + view->setEnabled(self && tab_count); + view->setVisible(self && edit); + + //For pick import/export - RK + view = getChildView("Import..."); + view->setVisible(self && edit); + view->setEnabled(tab_count < MAX_AVATAR_PICKS); + view = getChildView("Export..."); + view->setEnabled(self && tab_count); + view->setVisible(self); - childSetVisible("New...", true); - childSetVisible("Delete...", true); childSetVisible("loading_text", false); - - //For pick import and export - RK - childSetVisible("Import...", true); - childSetVisible("Export...", true); } } } // Create a new pick panel. It will automatically handle generating // its own id when it's time to save. -// static -void LLPanelAvatarPicks::onClickNew(void* data) +void LLPanelAvatarPicks::onClickNew() { // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) @@ -1207,25 +1075,26 @@ void LLPanelAvatarPicks::onClickNew(void* data) return; } // [/RLVa:KB] - LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; - LLPanelPick* panel_pick = new LLPanelPick(); - LLTabContainer* tabs = self->getChild("picks tab"); + LLPanelPick* panel_pick = new LLPanelPick; + LLTabContainer* tabs = getChild("picks tab"); panel_pick->initNewPick(); - if(tabs) - { - tabs->addTabPanel(panel_pick, panel_pick->getPickName()); - tabs->selectLastTab(); - } + tabs->addTabPanel(panel_pick, panel_pick->getPickName()); + tabs->selectLastTab(); + S32 tab_count = tabs->getTabCount(); + getChildView("New...")->setEnabled(tab_count < MAX_AVATAR_PICKS +// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) + && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); +// [/RLVa:KB] + getChildView("Delete...")->setEnabled(true); + getChildView("Import...")->setEnabled(tab_count < MAX_AVATAR_PICKS); } //Pick import and export - RK -// static -void LLPanelAvatarPicks::onClickImport(void* data) +void LLPanelAvatarPicks::onClickImport() { - LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; - self->mPanelPick = new LLPanelPick(); - self->mPanelPick->importNewPick(&LLPanelAvatarPicks::onClickImport_continued, data); + mPanelPick = new LLPanelPick; + mPanelPick->importNewPick(&LLPanelAvatarPicks::onClickImport_continued, this); } // static @@ -1233,84 +1102,72 @@ void LLPanelAvatarPicks::onClickImport_continued(void* data, bool import) { LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; LLTabContainer* tabs = self->getChild("picks tab"); - if(tabs && import && self->mPanelPick) + if (import && self->mPanelPick) { tabs->addTabPanel(self->mPanelPick, self->mPanelPick->getPickName()); tabs->selectLastTab(); + self->childSetEnabled("New...", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + self->childSetEnabled("Delete...", false); + self->childSetEnabled("Import...", tabs->getTabCount() < MAX_AVATAR_PICKS); } } -// static -void LLPanelAvatarPicks::onClickExport(void* data) +void LLPanelAvatarPicks::onClickExport() { - LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; - LLTabContainer* tabs = self->getChild("picks tab"); - LLPanelPick* panel_pick = tabs?(LLPanelPick*)tabs->getCurrentPanel():NULL; - + LLPanelPick* panel_pick = (LLPanelPick*)getChild("picks tab")->getCurrentPanel(); if (!panel_pick) return; panel_pick->exportPick(); } - -// static -void LLPanelAvatarPicks::onClickDelete(void* data) +void LLPanelAvatarPicks::onClickDelete() { - LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; - LLTabContainer* tabs = self->getChild("picks tab"); - LLPanelPick* panel_pick = tabs?(LLPanelPick*)tabs->getCurrentPanel():NULL; - + LLPanelPick* panel_pick = (LLPanelPick*)getChild("picks tab")->getCurrentPanel(); if (!panel_pick) return; LLSD args; args["PICK"] = panel_pick->getPickName(); LLNotificationsUtil::add("DeleteAvatarPick", args, LLSD(), - boost::bind(&LLPanelAvatarPicks::callbackDelete, self, _1, _2)); + boost::bind(&LLPanelAvatarPicks::callbackDelete, this, _1, _2)); } - -// static bool LLPanelAvatarPicks::callbackDelete(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); + if (option) return false; LLTabContainer* tabs = getChild("picks tab"); - LLPanelPick* panel_pick = tabs ? (LLPanelPick*)tabs->getCurrentPanel() : NULL; - LLMessageSystem* msg = gMessageSystem; - + LLPanelPick* panel_pick = (LLPanelPick*)tabs->getCurrentPanel(); if (!panel_pick) return false; - if (0 == option) - { - // If the viewer has a hacked god-mode, then this call will - // fail. - if(gAgent.isGodlike()) - { - msg->newMessage("PickGodDelete"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->nextBlock("Data"); - msg->addUUID("PickID", panel_pick->getPickID()); - // *HACK: We need to send the pick's creator id to accomplish - // the delete, and we don't use the query id for anything. JC - msg->addUUID( "QueryID", panel_pick->getPickCreatorID() ); - gAgent.sendReliableMessage(); - } - else - { - LLAvatarPropertiesProcessor::getInstance()->sendPickDelete(panel_pick->getPickID()); - } - + LLMessageSystem* msg = gMessageSystem; - if(tabs) - { - tabs->removeTabPanel(panel_pick); - } - delete panel_pick; - panel_pick = NULL; + // If the viewer has a hacked god-mode, then this call will fail. + if (gAgent.isGodlike()) + { + msg->newMessage("PickGodDelete"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgentID); + msg->addUUID("SessionID", gAgentSessionID); + msg->nextBlock("Data"); + msg->addUUID("PickID", panel_pick->getPickID()); + // *HACK: We need to send the pick's creator id to accomplish + // the delete, and we don't use the query id for anything. JC + msg->addUUID( "QueryID", panel_pick->getPickCreatorID() ); + gAgent.sendReliableMessage(); } - return false; + else + { + LLAvatarPropertiesProcessor::getInstance()->sendPickDelete(panel_pick->getPickID()); + } + + tabs->removeTabPanel(panel_pick); + delete panel_pick; + panel_pick = NULL; + childSetEnabled("New...", !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)); + childSetEnabled("Delete...", tabs->getTabCount()); + childSetEnabled("Import...", true); + return true; } @@ -1356,20 +1213,31 @@ LLPanelAvatar::LLPanelAvatar( selectTab(0); } -BOOL LLPanelAvatar::postBuild(void) +BOOL LLPanelAvatar::postBuild() { mTab = getChild("tab"); - getChild("Kick")->setCommitCallback(boost::bind(LLAvatarActions::kick, boost::bind(&LLPanelAvatar::getAvatarID, this))); - getChild("Freeze")->setCommitCallback(boost::bind(LLAvatarActions::freeze, boost::bind(&LLPanelAvatar::getAvatarID, this))); - getChild("Unfreeze")->setCommitCallback(boost::bind(LLAvatarActions::unfreeze, boost::bind(&LLPanelAvatar::getAvatarID, this))); - getChild("csr_btn")->setCommitCallback(boost::bind(LLAvatarActions::csr, boost::bind(&LLPanelAvatar::getAvatarID, this))); - childSetAction("OK", onClickOK, this); - childSetAction("Cancel", onClickCancel, this); - - childSetAction("copy_key",onClickGetKey,this); + LLUICtrl* ctrl = getChild("Kick"); + ctrl->setCommitCallback(boost::bind(LLAvatarActions::kick, boost::bind(&LLPanelAvatar::getAvatarID, this))); + ctrl->setVisible(false); + ctrl->setEnabled(false); + ctrl = getChild("Freeze"); + ctrl->setCommitCallback(boost::bind(LLAvatarActions::freeze, boost::bind(&LLPanelAvatar::getAvatarID, this))); + ctrl->setVisible(false); + ctrl->setEnabled(false); + ctrl = getChild("Unfreeze"); + ctrl->setCommitCallback(boost::bind(LLAvatarActions::unfreeze, boost::bind(&LLPanelAvatar::getAvatarID, this))); + ctrl->setVisible(false); + ctrl->setEnabled(false); + ctrl = getChild("csr_btn"); + ctrl->setCommitCallback(boost::bind(LLAvatarActions::csr, boost::bind(&LLPanelAvatar::getAvatarID, this))); + ctrl->setVisible(false); + ctrl->setEnabled(false); + getChild("OK")->setCommitCallback(boost::bind(&LLPanelAvatar::onClickOK, this)); + getChild("Cancel")->setCommitCallback(boost::bind(&LLPanelAvatar::onClickCancel, this)); + getChild("copy_key")->setCommitCallback(boost::bind(&LLPanelAvatar::onClickGetKey, this)); getChildView("web_profile")->setVisible(!gSavedSettings.getString("WebProfileURL").empty()); - if(mTab && !sAllowFirstLife) + if (mTab && !sAllowFirstLife) { LLPanel* panel = mTab->getPanelByName("1st Life"); if (panel) mTab->removeTabPanel(panel); @@ -1377,19 +1245,11 @@ BOOL LLPanelAvatar::postBuild(void) panel = mTab->getPanelByName("WebProfile"); if (panel) mTab->removeTabPanel(panel); } - childSetVisible("Kick",FALSE); - childSetEnabled("Kick",FALSE); - childSetVisible("Freeze",FALSE); - childSetEnabled("Freeze",FALSE); - childSetVisible("Unfreeze",FALSE); - childSetEnabled("Unfreeze",FALSE); - childSetVisible("csr_btn", FALSE); - childSetEnabled("csr_btn", FALSE); //This text never changes. We simply toggle visibility. - childSetVisible("online_yes", FALSE); - childSetColor("online_yes",LLColor4::green); - childSetValue("online_yes","Currently Online"); + ctrl = getChild("online_yes"); + ctrl->setVisible(false); + ctrl->setColor(LLColor4::green); return TRUE; } @@ -1399,6 +1259,7 @@ LLPanelAvatar::~LLPanelAvatar() { LLAvatarPropertiesProcessor::getInstance()->removeObserver(mAvatarID,this); sAllPanels.remove(this); + mCacheConnection.disconnect(); } @@ -1417,26 +1278,25 @@ void LLPanelAvatar::setOnlineStatus(EOnlineStatus online_status) { online_status = ONLINE_STATUS_YES; } - + if(mPanelSecondLife) - mPanelSecondLife->childSetVisible("online_yes", online_status == ONLINE_STATUS_YES); + mPanelSecondLife->childSetVisible("online_yes", online_status == ONLINE_STATUS_YES); // Since setOnlineStatus gets called after setAvatarID // need to make sure that "Offer Teleport" doesn't get set // to TRUE again for yourself - if (mAvatarID != gAgent.getID()) + if (mAvatarID != gAgentID) { childSetVisible("Offer Teleport...",TRUE); childSetVisible("Find on Map", true); } - BOOL in_prelude = gAgent.inPrelude(); - if(gAgent.isGodlike()) + if (gAgent.isGodlike()) { childSetEnabled("Offer Teleport...", TRUE); childSetToolTip("Offer Teleport...", getString("TeleportGod")); } - else if (in_prelude) + else if (gAgent.inPrelude()) { childSetEnabled("Offer Teleport...",FALSE); childSetToolTip("Offer Teleport...", getString("TeleportPrelude")); @@ -1465,12 +1325,8 @@ void LLPanelAvatar::setOnlineStatus(EOnlineStatus online_status) void LLPanelAvatar::onAvatarNameResponse(const LLUUID& agent_id, const LLAvatarName& av_name) { - std::string name; - if (gSavedSettings.getBOOL("SinguCompleteNameProfiles")) - name = av_name.getCompleteName(); - else - LLAvatarNameCache::getPNSName(av_name, name); - getChild("dnname")->setText(name); + mCacheConnection.disconnect(); + getChild("dnname")->setText(gSavedSettings.getBOOL("SinguCompleteNameProfiles") ? av_name.getCompleteName() : av_name.getNSName()); } void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id) @@ -1496,7 +1352,7 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id) // setOnlineStatus uses mIsFriend setOnlineStatus(ONLINE_STATUS_NO); - BOOL own_avatar = (mAvatarID == gAgent.getID() ); + bool own_avatar(mAvatarID == gAgentID); for(std::list::iterator it=mAvatarPanelList.begin();it!=mAvatarPanelList.end();++it) { @@ -1512,7 +1368,8 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id) if (LLDropTarget* drop_target = findChild("drop_target_rect")) drop_target->setEntityID(mAvatarID); - LLAvatarNameCache::get(avatar_id, boost::bind(&LLPanelAvatar::onAvatarNameResponse, this, _1, _2)); + mCacheConnection.disconnect(); + mCacheConnection = LLAvatarNameCache::get(avatar_id, boost::bind(&LLPanelAvatar::onAvatarNameResponse, this, _1, _2)); LLNameEditor* key_edit = getChild("avatar_key"); if(key_edit) @@ -1599,7 +1456,7 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id) avatar_key->setText(avatar_id.asString()); } } - + bool is_god = gAgent.isGodlike(); childSetVisible("Kick", is_god); childSetEnabled("Kick", is_god); @@ -1615,10 +1472,7 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id) void LLPanelAvatar::resetGroupList() { // only get these updates asynchronously via the group floater, which works on the agent only - if (mAvatarID != gAgent.getID()) - { - return; - } + if (mAvatarID != gAgentID) return; if (mPanelSecondLife) { @@ -1674,76 +1528,40 @@ void LLPanelAvatar::resetGroupList() } } -//static -void LLPanelAvatar::onClickGetKey(void *userdata) +void LLPanelAvatar::onClickGetKey() { - LLPanelAvatar* self = (LLPanelAvatar*)userdata; - LLUUID agent_id = self->getAvatarID(); + LLUUID agent_id = getAvatarID(); llinfos << "Copy agent id: " << agent_id << llendl; gViewerWindow->getWindow()->copyTextToClipboard(utf8str_to_wstring(agent_id.asString())); } -// static -void LLPanelAvatar::onClickOK(void *userdata) +void LLPanelAvatar::onClickOK() { - LLPanelAvatar *self = (LLPanelAvatar *)userdata; - // JC: Only save the data if we actually got the original // properties. Otherwise we might save blanks into // the database. - if (self - && self->mHaveProperties) + if (mHaveProperties) { - self->sendAvatarPropertiesUpdate(); + sendAvatarPropertiesUpdate(); - LLTabContainer* tabs = self->getChild("tab"); - if ( tabs->getCurrentPanel() != self->mPanelClassified ) + if (mTab->getCurrentPanel() != mPanelClassified || mPanelClassified->titleIsValid()) { - self->mPanelClassified->apply(); + mPanelClassified->apply(); - LLFloaterAvatarInfo *infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID); - if (infop) - { + if (LLFloaterAvatarInfo* infop = LLFloaterAvatarInfo::getInstance(mAvatarID)) infop->close(); - } - } - else - { - if ( self->mPanelClassified->titleIsValid() ) - { - self->mPanelClassified->apply(); - - LLFloaterAvatarInfo *infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID); - if (infop) - { - infop->close(); - } - } } } } -// static -void LLPanelAvatar::onClickCancel(void *userdata) +void LLPanelAvatar::onClickCancel() { - LLPanelAvatar *self = (LLPanelAvatar *)userdata; - - if (self) - { - LLFloaterAvatarInfo *infop; - if ((infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID))) - { - infop->close(); - } - else - { - // We're in the Search directory and are cancelling an edit - // to our own profile, so reset. - self->sendAvatarPropertiesRequest(); - } - } + if (LLFloaterAvatarInfo* infop = LLFloaterAvatarInfo::getInstance(mAvatarID)) + infop->close(); + else // We're in the Search directory and are cancelling an edit to our own profile, so reset. + sendAvatarPropertiesRequest(); } @@ -1825,14 +1643,8 @@ void LLPanelAvatar::processProperties(void* data, EAvatarProcessorType type) // Otherwise you will write blanks back into the database. void LLPanelAvatar::enableOKIfReady() { - if(mHaveProperties && childIsVisible("OK")) - { - childSetEnabled("OK", TRUE); - } - else - { - childSetEnabled("OK", FALSE); - } + LLView* OK(getChildView("OK")); + OK->setEnabled(mHaveProperties && OK->getVisible()); } void LLPanelAvatar::sendAvatarPropertiesUpdate() @@ -1877,25 +1689,16 @@ void LLPanelAvatar::sendAvatarPropertiesUpdate() void LLPanelAvatar::selectTab(S32 tabnum) { - if(mTab) - { - mTab->selectTab(tabnum); - } + if (mTab) mTab->selectTab(tabnum); } void LLPanelAvatar::selectTabByName(std::string tab_name) { - if (mTab) - { - if (tab_name.empty()) - { - mTab->selectFirstTab(); - } - else - { - mTab->selectTabByName(tab_name); - } - } + if (!mTab) return; + if (tab_name.empty()) + mTab->selectFirstTab(); + else + mTab->selectTabByName(tab_name); } void* LLPanelAvatar::createPanelAvatarSecondLife(void* data) diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index a7c18e796..efb9aabe4 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -88,12 +88,10 @@ class LLPanelAvatarFirstLife : public LLPanelAvatarTab public: LLPanelAvatarFirstLife(const std::string& name, const LLRect &rect, LLPanelAvatar* panel_avatar); - /*virtual*/ BOOL postBuild(void); - + /*virtual*/ BOOL postBuild(); /*virtual*/ void processProperties(void* data, EAvatarProcessorType type); - static void onClickImage( void *userdata); - + void onClickImage(); void enableControls(BOOL own_avatar); }; @@ -104,30 +102,29 @@ class LLPanelAvatarSecondLife { public: LLPanelAvatarSecondLife(const std::string& name, const LLRect &rect, LLPanelAvatar* panel_avatar ); + ~LLPanelAvatarSecondLife(); - /*virtual*/ BOOL postBuild(void); + /*virtual*/ BOOL postBuild(); /*virtual*/ void refresh(); /*virtual*/ void processProperties(void* data, EAvatarProcessorType type); - static void onClickImage( void *userdata); - static void onClickFriends( void *userdata); - static void onDoubleClickGroup(void* userdata); - static void onClickPublishHelp(void *userdata); - static void onClickPartnerHelp(void *userdata); + void onClickImage(); + void onClickFriends(); + void onDoubleClickGroup(); static bool onClickPartnerHelpLoadURL(const LLSD& notification, const LLSD& response); - static void onClickPartnerInfo(void *userdata); // Clear out the controls anticipating new network data. void clearControls(); void enableControls(BOOL own_avatar); void updateOnlineText(BOOL online, BOOL have_calling_card); - void updatePartnerName(); + void updatePartnerName(const LLAvatarName& name); void setPartnerID(LLUUID id) { mPartnerID = id; } private: LLUUID mPartnerID; + boost::signals2::connection mCacheConnection; }; @@ -139,7 +136,7 @@ class LLPanelAvatarWeb : public: LLPanelAvatarWeb(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar); /*virtual*/ ~LLPanelAvatarWeb(); - /*virtual*/ BOOL postBuild(void); + /*virtual*/ BOOL postBuild(); /*virtual*/ void refresh(); @@ -149,11 +146,8 @@ public: void setWebURL(std::string url); - void load(std::string url); - void onURLKeystroke(LLLineEditor* editor); + void load(const std::string& url); void onCommitLoad(const LLSD& value); - void onCommitURL(const LLSD& value); - static void onClickWebProfileHelp(void *); // inherited from LLViewerMediaObserver /*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event); @@ -170,7 +164,7 @@ class LLPanelAvatarAdvanced : public LLPanelAvatarTab public: LLPanelAvatarAdvanced(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar); - /*virtual*/ BOOL postBuild(void); + /*virtual*/ BOOL postBuild(); /*virtual*/ void processProperties(void* data, EAvatarProcessorType type); @@ -197,7 +191,7 @@ class LLPanelAvatarNotes : public LLPanelAvatarTab public: LLPanelAvatarNotes(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar); - /*virtual*/ BOOL postBuild(void); + /*virtual*/ BOOL postBuild(); /*virtual*/ void refresh(); @@ -212,7 +206,7 @@ class LLPanelAvatarClassified : public LLPanelAvatarTab public: LLPanelAvatarClassified(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar); - /*virtual*/ BOOL postBuild(void); + /*virtual*/ BOOL postBuild(); /*virtual*/ void refresh(); @@ -230,11 +224,13 @@ public: void deleteClassifiedPanels(); private: - static void onClickNew(void* data); - static void onClickDelete(void* data); + void onClickNew(); + void onClickDelete(); bool callbackDelete(const LLSD& notification, const LLSD& response); bool callbackNew(const LLSD& notification, const LLSD& response); + + bool mInDirectory; }; @@ -253,13 +249,13 @@ public: void deletePickPanels(); private: - static void onClickNew(void* data); - static void onClickDelete(void* data); + void onClickNew(); + void onClickDelete(); //Pick import and export - RK - static void onClickImport(void* data); + void onClickImport(); static void onClickImport_continued(void* self, bool import); - static void onClickExport(void* data); + void onClickExport(); bool callbackDelete(const LLSD& notification, const LLSD& response); @@ -310,12 +306,12 @@ public: void selectTab(S32 tabnum); void selectTabByName(std::string tab_name); - BOOL haveData() { return mHaveProperties && mHaveStatistics; } - BOOL isEditable() const { return mAllowEdit; } + bool haveData() const { return mHaveProperties && mHaveStatistics; } + bool isEditable() const { return mAllowEdit; } - static void onClickGetKey(void *userdata); - static void onClickOK( void *userdata); - static void onClickCancel( void *userdata); + void onClickGetKey(); + void onClickOK(); + void onClickCancel(); private: void enableOKIfReady(); @@ -347,15 +343,16 @@ public: private: LLUUID mAvatarID; // for which avatar is this window? - BOOL mIsFriend; // Are we friends? - BOOL mHaveProperties; - BOOL mHaveStatistics; + bool mIsFriend; // Are we friends? + bool mHaveProperties; + bool mHaveStatistics; // only update note if data received from database and // note is changed from database version bool mHaveNotes; std::string mLastNotes; LLTabContainer* mTab; - BOOL mAllowEdit; + bool mAllowEdit; + boost::signals2::connection mCacheConnection; typedef std::list panel_list_t; static panel_list_t sAllPanels; diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index c6e290963..6b5b4123f 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -159,9 +159,7 @@ void LLPanelGroupBulkImpl::onAvatarNameCache(const LLUUID& agent_id, const LLAva std::vector names; uuid_vec_t agent_ids; agent_ids.push_back(agent_id); - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - names.push_back(name); + names.push_back(av_name.getNSName()); addUsers(names, agent_ids); } @@ -351,9 +349,7 @@ void LLPanelGroupBulk::addUserCallback(const LLUUID& id, const LLAvatarName& av_ std::vector names; uuid_vec_t agent_ids; agent_ids.push_back(id); - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - names.push_back(name); + names.push_back(av_name.getNSName()); mImplementation->addUsers(names, agent_ids); } @@ -411,9 +407,7 @@ void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) } else { - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - names.push_back(name); + names.push_back(av_name.getNSName()); } } } diff --git a/indra/newview/llpanelgroupbulk.h b/indra/newview/llpanelgroupbulk.h index d03e4fca2..4c8081b73 100644 --- a/indra/newview/llpanelgroupbulk.h +++ b/indra/newview/llpanelgroupbulk.h @@ -71,3 +71,4 @@ protected: }; #endif // LL_LLPANELGROUPBULK_H + diff --git a/indra/newview/llpanelgroupbulkban.cpp b/indra/newview/llpanelgroupbulkban.cpp index 1899689d7..5915d355f 100644 --- a/indra/newview/llpanelgroupbulkban.cpp +++ b/indra/newview/llpanelgroupbulkban.cpp @@ -31,6 +31,7 @@ #include "llagent.h" #include "llavatarnamecache.h" +#include "llavataractions.h" #include "llfloateravatarpicker.h" #include "llbutton.h" #include "llcallingcard.h" @@ -101,6 +102,9 @@ BOOL LLPanelGroupBulkBan::postBuild() } mImplementation->mTooManySelected = getString("ban_selection_too_large"); + mImplementation->mBanNotPermitted = getString("ban_not_permitted"); + mImplementation->mBanLimitFail = getString("ban_limit_fail"); + mImplementation->mCannotBanYourself = getString("cant_ban_yourself"); update(); return TRUE; @@ -108,6 +112,25 @@ BOOL LLPanelGroupBulkBan::postBuild() void LLPanelGroupBulkBan::submit() { + if (!gAgent.hasPowerInGroup(mImplementation->mGroupID, GP_GROUP_BAN_ACCESS)) + { + // Fail! Agent no longer have ban rights. Permissions could have changed after button was pressed. + LLSD msg; + msg["MESSAGE"] = mImplementation->mBanNotPermitted; + LLNotificationsUtil::add("GenericAlert", msg); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + return; + } + LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + if (group_datap && group_datap->mBanList.size() >= GB_MAX_BANNED_AGENTS) + { + // Fail! Size limit exceeded. List could have updated after button was pressed. + LLSD msg; + msg["MESSAGE"] = mImplementation->mBanLimitFail; + LLNotificationsUtil::add("GenericAlert", msg); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + return; + } std::vector banned_agent_list; std::vector agents = mImplementation->mBulkAgentList->getAllData(); std::vector::iterator iter = agents.begin(); @@ -117,8 +140,8 @@ void LLPanelGroupBulkBan::submit() banned_agent_list.push_back(agent->getUUID()); } - const S32 MAX_GROUP_BANS = 100; // Max invites per request. 100 to match server cap. - if (banned_agent_list.size() > MAX_GROUP_BANS) + const S32 MAX_BANS_PER_REQUEST = 100; // Max bans per request. 100 to match server cap. + if (banned_agent_list.size() > MAX_BANS_PER_REQUEST) { // Fail! LLSD msg; @@ -128,33 +151,100 @@ void LLPanelGroupBulkBan::submit() return; } - LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + // remove already banned users and yourself from request. + std::vector banned_avatar_names; + std::vector out_of_limit_names; + bool banning_self = FALSE; + std::vector::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), gAgent.getID()); + if (conflict != banned_agent_list.end()) + { + banned_agent_list.erase(conflict); + banning_self = TRUE; + } if (group_datap) { BOOST_FOREACH(const LLGroupMgrGroupData::ban_list_t::value_type& group_ban_pair, group_datap->mBanList) { const LLUUID& group_ban_agent_id = group_ban_pair.first; - if (std::find(banned_agent_list.begin(), banned_agent_list.end(), group_ban_agent_id) != banned_agent_list.end()) + std::vector::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), group_ban_agent_id); + if (conflict != banned_agent_list.end()) { - // Fail! - std::string av_name; - LLAvatarNameCache::getPNSName(group_ban_agent_id, av_name); + LLAvatarName av_name; + LLAvatarNameCache::get(group_ban_agent_id, &av_name); + banned_avatar_names.push_back(av_name); - LLStringUtil::format_map_t string_args; - string_args["[RESIDENT]"] = av_name; - - LLSD msg; - msg["MESSAGE"] = getString("already_banned", string_args); - LLNotificationsUtil::add("GenericAlert", msg); - (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); - return; + banned_agent_list.erase(conflict); + if (banned_agent_list.size() == 0) + { + break; + } } } + // this check should always be the last one before we send the request. + // Otherwise we have a possibility of cutting more then we need to. + if (banned_agent_list.size() > GB_MAX_BANNED_AGENTS - group_datap->mBanList.size()) + { + std::vector::iterator exeedes_limit = banned_agent_list.begin() + GB_MAX_BANNED_AGENTS - group_datap->mBanList.size(); + for (std::vector::iterator itor = exeedes_limit ; + itor != banned_agent_list.end(); ++itor) + { + LLAvatarName av_name; + LLAvatarNameCache::get(*itor, &av_name); + out_of_limit_names.push_back(av_name); + } + banned_agent_list.erase(exeedes_limit,banned_agent_list.end()); + } } - LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); - LLGroupMgr::getInstance()->sendGroupMemberEjects(mImplementation->mGroupID, banned_agent_list); + // sending request and ejecting members + if (banned_agent_list.size() != 0) + { + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); + LLGroupMgr::getInstance()->sendGroupMemberEjects(mImplementation->mGroupID, banned_agent_list); + } + + // building notification + if (banned_avatar_names.size() > 0 || banning_self || out_of_limit_names.size() > 0) + { + std::string reasons; + if(banned_avatar_names.size() > 0) + { + reasons = "\n " + buildResidentsArgument(banned_avatar_names, "residents_already_banned"); + } + + if(banning_self) + { + reasons += "\n " + mImplementation->mCannotBanYourself; + } + + if(out_of_limit_names.size() > 0) + { + reasons += "\n " + buildResidentsArgument(out_of_limit_names, "ban_limit_reached"); + } + + LLStringUtil::format_map_t msg_args; + msg_args["[REASONS]"] = reasons; + LLSD msg; + if (banned_agent_list.size() == 0) + { + msg["MESSAGE"] = getString("ban_failed", msg_args); + } + else + { + msg["MESSAGE"] = getString("partial_ban", msg_args); + } + LLNotificationsUtil::add("GenericAlert", msg); + } //then close (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); } + +std::string LLPanelGroupBulkBan::buildResidentsArgument(std::vector avatar_names, const std::string &format) +{ + std::string names_string; + LLAvatarActions::buildResidentsString(avatar_names, names_string); + LLStringUtil::format_map_t args; + args["[RESIDENTS]"] = names_string; + return getString(format, args); +} diff --git a/indra/newview/llpanelgroupbulkban.h b/indra/newview/llpanelgroupbulkban.h index a4c071230..150bb43c7 100644 --- a/indra/newview/llpanelgroupbulkban.h +++ b/indra/newview/llpanelgroupbulkban.h @@ -40,7 +40,10 @@ public: virtual BOOL postBuild(); + //static void callbackClickSubmit(void* userdata); virtual void submit(); +private: + std::string buildResidentsArgument(std::vector avatar_names, const std::string &format); }; #endif // LL_LLPANELGROUPBULKBAN_H diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 154b4cecf..235eeb8f9 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -74,6 +74,9 @@ public: std::string mLoadingText; std::string mTooManySelected; + std::string mBanNotPermitted; + std::string mBanLimitFail; + std::string mCannotBanYourself; std::set mInviteeIDs; @@ -94,3 +97,4 @@ public: }; #endif // LL_LLPANELGROUPBULKIMPL_H + diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 5ae135380..122136654 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -51,6 +51,8 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" +#include + class LLPanelGroupInvite::impl : public boost::signals2::trackable { public: @@ -69,7 +71,7 @@ public: static void callbackClickAdd(void* userdata); static void callbackClickRemove(void* userdata); static void callbackSelect(LLUICtrl* ctrl, void* userdata); - void callbackAddUsers(const uuid_vec_t& agent_idsa); + void callbackAddUsers(const uuid_vec_t& agent_ids); void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); @@ -93,6 +95,8 @@ public: void (*mCloseCallback)(void* data); void* mCloseCallbackUserData; + + std::map mAvatarNameCacheConnection; }; @@ -106,14 +110,20 @@ LLPanelGroupInvite::impl::impl(const LLUUID& group_id): mGroupName( NULL ), mConfirmedOwnerInvite( false ), mCloseCallback( NULL ), - mCloseCallbackUserData( NULL ) + mCloseCallbackUserData( NULL ), + mAvatarNameCacheConnection() { } LLPanelGroupInvite::impl::~impl() { + for (std::map::const_iterator it = mAvatarNameCacheConnection.begin(); it != mAvatarNameCacheConnection.end(); ++it) + if ((*it).second.connected()) + (*it).second.disconnect(); } +const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. + void LLPanelGroupInvite::impl::addUsers(const std::vector& names, const uuid_vec_t& agent_ids) { @@ -191,7 +201,6 @@ void LLPanelGroupInvite::impl::submitInvitations() role_member_pairs[item->getUUID()] = role_id; } - const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. if (role_member_pairs.size() > MAX_GROUP_INVITES) { // Fail! @@ -381,7 +390,12 @@ void LLPanelGroupInvite::impl::callbackAddUsers(const uuid_vec_t& agent_ids) std::vector names; for (S32 i = 0; i < (S32)agent_ids.size(); i++) { - LLAvatarNameCache::get(agent_ids[i], + const LLUUID& id(agent_ids[i]); + if (mAvatarNameCacheConnection[id].connected()) + { + mAvatarNameCacheConnection[id].disconnect(); + } + mAvatarNameCacheConnection[id] = LLAvatarNameCache::get(id, boost::bind(&LLPanelGroupInvite::impl::onAvatarNameCache, this, _1, _2)); } } @@ -389,6 +403,10 @@ void LLPanelGroupInvite::impl::callbackAddUsers(const uuid_vec_t& agent_ids) void LLPanelGroupInvite::impl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) { + if (mAvatarNameCacheConnection[agent_id].connected()) + { + mAvatarNameCacheConnection[agent_id].disconnect(); + } std::vector names; uuid_vec_t agent_ids; agent_ids.push_back(agent_id); @@ -476,9 +494,7 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) } else { - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - names.push_back(name); + names.push_back(av_name.getNSName()); } } } @@ -491,9 +507,7 @@ void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const LLAvatarName& a std::vector names; uuid_vec_t agent_ids; agent_ids.push_back(id); - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - names.push_back(name); + names.push_back(av_name.getNSName()); mImplementation->addUsers(names, agent_ids); } diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index d9afd5b04..6ceb330c1 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -74,7 +74,7 @@ bool agentCanAddToRole(const LLUUID& group_id, if (!gdatap) { llwarns << "agentCanAddToRole " - << "-- No group data!" << llendl; + << "-- No group data!" << LL_ENDL; return false; } @@ -783,7 +783,7 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl, // Regardless of whether or not this ability is allowed by all or some, we want to prevent // the group managers from accidentally disabling either of the two additional abilities - // tied with GP_GROUP_BAN_ACCESS + // tied with GP_GROUP_BAN_ACCESS. if ( (allowed_by_all & GP_GROUP_BAN_ACCESS) == GP_GROUP_BAN_ACCESS || (allowed_by_some & GP_GROUP_BAN_ACCESS) == GP_GROUP_BAN_ACCESS) { @@ -1218,7 +1218,7 @@ void LLPanelGroupMembersSubTab::sendEjectNotifications(const LLUUID& group_id, c { LLSD args; std::string av_name; - LLAvatarNameCache::getPNSName(*i, av_name); + LLAvatarNameCache::getNSName(*i, av_name); args["AVATAR_NAME"] = av_name; args["GROUP_NAME"] = group_data->mName; @@ -1699,6 +1699,12 @@ void LLPanelGroupMembersSubTab::addMemberToList(LLGroupMemberData* data) mHasMatch = TRUE; } +const S32& group_member_name_system() +{ + static const LLCachedControl name_system("GroupMembersNameSystem", 0); + return name_system; +} + void LLPanelGroupMembersSubTab::onNameCache(const LLUUID& update_id, LLGroupMemberData* member, const LLAvatarName& av_name, const LLUUID& av_id) { avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(av_id); @@ -1720,9 +1726,8 @@ void LLPanelGroupMembersSubTab::onNameCache(const LLUUID& update_id, LLGroupMemb } // trying to avoid unnecessary hash lookups - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); // Singu Note: Diverge from LL Viewer and filter by name displayed - if (matchesSearchFilter(name)) + // Singu Note: Diverge from LL Viewer and filter by name displayed + if (matchesSearchFilter(av_name.getNSName(group_member_name_system()))) { addMemberToList(member); if(!mMembersList->getEnabled()) @@ -1771,11 +1776,11 @@ void LLPanelGroupMembersSubTab::updateMembers() continue; // Do filtering on name if it is already in the cache. - // Singu Note: Diverge from LL Viewer and filter by name displayed - std::string fullname; - if (LLAvatarNameCache::getPNSName(mMemberProgress->first, fullname)) + LLAvatarName av_name; + if (LLAvatarNameCache::get(mMemberProgress->first, &av_name)) { - if (matchesSearchFilter(fullname)) + // Singu Note: Diverge from LL Viewer and filter by name displayed + if (matchesSearchFilter(av_name.getNSName(group_member_name_system()))) { addMemberToList(mMemberProgress->second); } diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 2d0501ff5..c1a497e39 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -92,7 +92,7 @@ void LLSpeaker::onNameCache(const LLAvatarName& full_name) if (!name_system) mDisplayName = gCacheName->cleanFullName(full_name.getLegacyName()); else - LLAvatarNameCache::getPNSName(full_name, mDisplayName, name_system); + mDisplayName = full_name.getNSName(name_system); } bool LLSpeaker::isInVoiceChannel() diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 3621179de..f269f82db 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3524,10 +3524,10 @@ void LLStartUp::initNameCache() // Start cache in not-running state until we figure out if we have // capabilities for display name lookup - LLAvatarNameCache::initClass(false); S32 phoenix_name_system = gSavedSettings.getS32("PhoenixNameSystem"); - if(phoenix_name_system <= 0 || phoenix_name_system > 3) LLAvatarNameCache::setUseDisplayNames(false); - else LLAvatarNameCache::setUseDisplayNames(true); + LLAvatarNameCache::initClass(false, gSavedSettings.getBOOL("UsePeopleAPI")); + LLAvatarNameCache::setUseDisplayNames(phoenix_name_system > 0 && phoenix_name_system < 4); + LLAvatarNameCache::setUseUsernames(!phoenix_name_system || phoenix_name_system == 1 || phoenix_name_system == 3); } void LLStartUp::cleanupNameCache() diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp index 26ef02e77..27da1e0ba 100644 --- a/indra/newview/llviewerdisplayname.cpp +++ b/indra/newview/llviewerdisplayname.cpp @@ -40,9 +40,6 @@ #include "llnotificationsutil.h" #include "llui.h" // getLanguage() -class AIHTTPTimeoutPolicy; -extern AIHTTPTimeoutPolicy setDisplayNameResponder_timeout; - namespace LLViewerDisplayName { // Fired when viewer receives server response to display name change @@ -56,19 +53,21 @@ namespace LLViewerDisplayName sNameChangedSignal.connect(cb); } + void doNothing() { } } class LLSetDisplayNameResponder : public LLHTTPClient::ResponderIgnoreBody { -public: + LOG_CLASS(LLSetDisplayNameResponder); +private: // only care about errors - /*virtual*/ void httpFailure(void) + /*virtual*/ void httpFailure() { + llwarns << dumpResponse() << LL_ENDL; LLViewerDisplayName::sSetDisplayNameSignal(false, "", LLSD()); LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots(); } - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return setDisplayNameResponder_timeout; } /*virtual*/ char const* getName(void) const { return "LLSetDisplayNameResponder"; } }; @@ -102,7 +101,7 @@ void LLViewerDisplayName::set(const std::string& display_name, const set_name_sl // People API expects array of [ "old value", "new value" ] LLSD change_array = LLSD::emptyArray(); - change_array.append(av_name.mDisplayName); + change_array.append(av_name.getDisplayName()); change_array.append(display_name); llinfos << "Set name POST to " << cap_url << llendl; @@ -130,7 +129,7 @@ public: LLSD body = input["body"]; S32 status = body["status"].asInteger(); - bool success = (status == 200); + bool success = (status == HTTP_OK); std::string reason = body["reason"].asString(); LLSD content = body["content"]; @@ -139,14 +138,14 @@ public: // If viewer's concept of display name is out-of-date, the set request // will fail with 409 Conflict. If that happens, fetch up-to-date // name information. - if (status == 409) + if (status == HTTP_CONFLICT) { LLUUID agent_id = gAgent.getID(); // Flush stale data LLAvatarNameCache::erase( agent_id ); - // Queue request for new data - LLAvatarName ignored; - LLAvatarNameCache::get( agent_id, &ignored ); + // Queue request for new data: nothing to do on callback though... + // Note: no need to disconnect the callback as it never gets out of scope + LLAvatarNameCache::get(agent_id, boost::bind(&LLViewerDisplayName::doNothing)); // Kill name tag, as it is wrong LLVOAvatar::invalidateNameTag( agent_id ); } @@ -160,7 +159,6 @@ public: class LLDisplayNameUpdate : public LLHTTPNode { - /*virtual*/ void post( LLHTTPNode::ResponsePtr response, const LLSD& context, @@ -178,14 +176,15 @@ class LLDisplayNameUpdate : public LLHTTPNode llinfos << "name-update now " << LLDate::now() << " next_update " << LLDate(av_name.mNextUpdate) - << llendl; + << LL_ENDL; // Name expiration time may be provided in headers, or we may use a // default value // *TODO: get actual headers out of ResponsePtr //LLSD headers = response->mHeaders; + AIHTTPReceivedHeaders headers; av_name.mExpires = - LLAvatarNameCache::nameExpirationFromHeaders(AIHTTPReceivedHeaders()); + LLAvatarNameCache::nameExpirationFromHeaders(headers); LLAvatarNameCache::insert(agent_id, av_name); @@ -196,8 +195,8 @@ class LLDisplayNameUpdate : public LLHTTPNode { LLSD args; args["OLD_NAME"] = old_display_name; - args["SLID"] = av_name.mUsername; - args["NEW_NAME"] = av_name.mDisplayName; + args["SLID"] = av_name.getUserName(); + args["NEW_NAME"] = av_name.getDisplayName(); LLNotificationsUtil::add("DisplayNameUpdate", args); } if (agent_id == gAgent.getID()) @@ -214,4 +213,3 @@ LLHTTPRegistration LLHTTPRegistration gHTTPRegistrationMessageDisplayNameUpdate( "/message/DisplayNameUpdate"); - diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 444247924..d8211167c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3811,12 +3811,11 @@ class LLEditEnableCustomizeAvatar : public view_listener_t class LLEditEnableChangeDisplayname : public view_listener_t { - bool handleEvent(LLPointer event, const LLSD& userdata) - { - bool new_value = LLAvatarNameCache::useDisplayNames(); - gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); - return true; - } + bool handleEvent(LLPointer event, const LLSD& userdata) + { + gMenuHolder->findControl(userdata["control"].asString())->setValue(LLAvatarName::useDisplayNames()); + return true; + } }; bool is_object_sittable() diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 396fe12d5..a5033696f 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2096,7 +2096,7 @@ static std::string clean_name_from_task_im(const std::string& msg, // Don't try to clean up group names if (!from_group) { - if (LLAvatarNameCache::useDisplayNames()) + if (LLAvatarName::useDisplayNames()) { // ...just convert to username final += LLCacheName::buildUsername(name); @@ -2119,22 +2119,20 @@ void notification_display_name_callback(const LLUUID& id, LLSD& substitutions, const LLSD& payload) { - substitutions["NAME"] = av_name.mDisplayName; + substitutions["NAME"] = av_name.getDisplayName(); LLNotificationsUtil::add(name, substitutions, payload); } // Callback for name resolution of a god/estate message void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string message) { - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); LLSD args; - args["NAME"] = name; + args["NAME"] = av_name.getNSName(); args["MESSAGE"] = message; LLNotificationsUtil::add("GodMessage", args); // Treat like a system message and put in chat history. - chat.mText = name + ": " + message; + chat.mText = av_name.getNSName() + ": " + message; // Claim to be from a local agent so it doesn't go into console. LLFloaterChat::addChat(chat, false, true); @@ -2155,7 +2153,7 @@ std::string replace_wildcards(std::string autoresponse, const LLUUID& id, const // Add in their display name LLAvatarName av_name; - boost::algorithm::replace_all(autoresponse, "#d", LLAvatarNameCache::get(id, &av_name) ? av_name.mDisplayName : name); + boost::algorithm::replace_all(autoresponse, "#d", LLAvatarNameCache::get(id, &av_name) ? av_name.getDisplayName() : name); if (!isAgentAvatarValid()) return autoresponse; // Add in idle time @@ -2453,11 +2451,11 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) session_id); gAgent.sendReliableMessage(); - std::string pns_name; - if (!LLAvatarNameCache::getPNSName(from_id, pns_name)) pns_name = name; + LLAvatarName av_name; + std::string ns_name = LLAvatarNameCache::get(from_id, &av_name) ? av_name.getNSName() : name; if (show_autoresponded) { - gIMMgr->addMessage(session_id, from_id, name, LLTrans::getString("IM_autoresponded_to") + " " + pns_name); + gIMMgr->addMessage(session_id, from_id, name, LLTrans::getString("IM_autoresponded_to") + " " + ns_name); } if (LLViewerInventoryItem* item = gInventory.getItem(itemid)) { @@ -2465,7 +2463,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if (show_autoresponded) { gIMMgr->addMessage(computed_session_id, from_id, name, - llformat("%s %s \"%s\"", pns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); + llformat("%s %s \"%s\"", ns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); } } } @@ -2584,14 +2582,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // Don't announce that someone has started messaging, if they're muted or when in busy mode if (!is_muted && (!accept_im_from_only_friend || is_friend) && !is_do_not_disturb && !gIMMgr->hasSession(computed_session_id) && gSavedSettings.getBOOL("AscentInstantMessageAnnounceIncoming")) { - std::string pns_name; - if (!LLAvatarNameCache::getPNSName(from_id, pns_name)) pns_name = name; + LLAvatarName av_name; + std::string ns_name = LLAvatarNameCache::get(from_id, &av_name) ? av_name.getNSName() : name; gIMMgr->addMessage( computed_session_id, from_id, name, - llformat("%s ", pns_name.c_str()) + LLTrans::getString("IM_announce_incoming"), + llformat("%s ", ns_name.c_str()) + LLTrans::getString("IM_announce_incoming"), name, IM_NOTHING_SPECIAL, parent_estate_id, @@ -2628,7 +2626,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if (show_autoresponded) { - gIMMgr->addMessage(session_id, from_id, name, LLTrans::getString("IM_autoresponded_to") + " " + pns_name); + gIMMgr->addMessage(session_id, from_id, name, LLTrans::getString("IM_autoresponded_to") + " " + ns_name); } if (LLViewerInventoryItem* item = gInventory.getItem(itemid)) { @@ -2636,7 +2634,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if (show_autoresponded) { gIMMgr->addMessage(computed_session_id, from_id, name, - llformat("%s %s \"%s\"", pns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); + llformat("%s %s \"%s\"", ns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); } } } @@ -3486,11 +3484,11 @@ void send_do_not_disturb_message (LLMessageSystem* msg, const LLUUID& from_id, c IM_ONLINE, IM_BUSY_AUTO_RESPONSE); gAgent.sendReliableMessage(); - std::string pns_name; - if (!LLAvatarNameCache::getPNSName(from_id, pns_name)) pns_name = from_name; + LLAvatarName av_name; + std::string ns_name = LLAvatarNameCache::get(from_id, &av_name) ? av_name.getNSName() : from_name; LLUUID session_id; msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, session_id); - if (gSavedPerAccountSettings.getBOOL("BusyModeResponseShow")) gIMMgr->addMessage(session_id, from_id, from_name, LLTrans::getString("IM_autoresponded_to") + " " + pns_name); + if (gSavedPerAccountSettings.getBOOL("BusyModeResponseShow")) gIMMgr->addMessage(session_id, from_id, from_name, LLTrans::getString("IM_autoresponded_to") + " " + ns_name); if (!gSavedPerAccountSettings.getBOOL("BusyModeResponseItem")) return; // Not sending an item, finished if (LLViewerInventoryItem* item = gInventory.getItem(static_cast(gSavedPerAccountSettings.getString("BusyModeResponseItemID")))) { @@ -3499,7 +3497,7 @@ void send_do_not_disturb_message (LLMessageSystem* msg, const LLUUID& from_id, c LLUUID computed_session_id = LLIMMgr::computeSessionID(static_cast(d), from_id); LLGiveInventory::doGiveInventoryItem(from_id, item, computed_session_id); if (gSavedPerAccountSettings.getBOOL("BusyModeResponseShow")) - gIMMgr->addMessage(computed_session_id, from_id, from_name, llformat("%s %s \"%s\"", pns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); + gIMMgr->addMessage(computed_session_id, from_id, from_name, llformat("%s %s \"%s\"", ns_name.c_str(), LLTrans::getString("IM_autoresponse_sent_item").c_str(), item->getName().c_str())); } } } @@ -3794,7 +3792,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) LLAvatarName av_name; if (LLAvatarNameCache::get(from_id, &av_name)) { - chat.mFromName = av_name.mDisplayName; + chat.mFromName = av_name.getDisplayName(); } else { @@ -3997,7 +3995,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) if (chatter && chatter->isAvatar()) { - if (LLAvatarNameCache::getPNSName(from_id, from_name)) + if (LLAvatarNameCache::getNSName(from_id, from_name)) chat.mFromName = from_name; } @@ -6275,15 +6273,14 @@ static void money_balance_avatar_notify(const LLUUID& agent_id, { bool no_transaction_clutter = gSavedSettings.getBOOL("LiruNoTransactionClutter"); std::string notification = no_transaction_clutter ? "Payment" : "SystemMessage"; - std::string name; - LLAvatarNameCache::getPNSName(av_name,name); - args["NAME"] = name; + args["NAME"] = av_name.getNSName(); LLSD msg_args; msg_args["MESSAGE"] = LLTrans::getString(message,args); LLNotificationsUtil::add(notification,msg_args,payload); if (!no_transaction_clutter) LLFloaterChat::addChat(msg_args["MESSAGE"].asString()); // Alerts won't automatically log to chat. } + static void process_money_balance_reply_extended(LLMessageSystem* msg) { // Added in server 1.40 and viewer 2.1, support for localization @@ -6500,83 +6497,101 @@ bool handle_special_notification(std::string notificationID, LLSD& llsdBlock) } // some of the server notifications need special handling. This is where we do that. -bool handle_teleport_access_blocked(LLSD& llsdBlock) +bool handle_teleport_access_blocked(LLSD& llsdBlock, const std::string & notificationID, const std::string & defaultMessage) { - std::string notificationID("TeleportEntryAccessBlocked"); U8 regionAccess = static_cast(llsdBlock["_region_access"].asInteger()); std::string regionMaturity = LLViewerRegion::accessToString(regionAccess); LLStringUtil::toLower(regionMaturity); llsdBlock["REGIONMATURITY"] = regionMaturity; bool returnValue = false; - LLNotificationPtr maturityLevelNotification; - std::string notifySuffix = "_Notify"; - if (regionAccess == SIM_ACCESS_MATURE) - { - if (gAgent.isTeen()) - { - gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock); - returnValue = true; + LLNotificationPtr tp_failure_notification; + std::string notifySuffix; - notifySuffix = "_NotifyAdultsOnly"; - } - else if (gAgent.prefersPG()) + if (notificationID == std::string("TeleportEntryAccessBlocked")) + { + notifySuffix = "_Notify"; + if (regionAccess == SIM_ACCESS_MATURE) { - if (gAgent.hasRestartableFailedTeleportRequest()) + if (gAgent.isTeen()) { - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback); + gAgent.clearTeleportRequest(); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock); returnValue = true; + + notifySuffix = "_NotifyAdultsOnly"; + } + else if (gAgent.prefersPG()) + { + if (gAgent.hasRestartableFailedTeleportRequest()) + { + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback); + returnValue = true; + } + else + { + gAgent.clearTeleportRequest(); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); + returnValue = true; + } } else { gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); returnValue = true; } } - else + else if (regionAccess == SIM_ACCESS_ADULT) { - gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); - returnValue = true; - } - } - else if (regionAccess == SIM_ACCESS_ADULT) - { - if (!gAgent.isAdult()) - { - gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock); - returnValue = true; - - notifySuffix = "_NotifyAdultsOnly"; - } - else if (gAgent.prefersPG() || gAgent.prefersMature()) - { - if (gAgent.hasRestartableFailedTeleportRequest()) + if (!gAgent.isAdult()) { - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback); + gAgent.clearTeleportRequest(); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock); returnValue = true; + + notifySuffix = "_NotifyAdultsOnly"; + } + else if (gAgent.prefersPG() || gAgent.prefersMature()) + { + if (gAgent.hasRestartableFailedTeleportRequest()) + { + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback); + returnValue = true; + } + else + { + gAgent.clearTeleportRequest(); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); + returnValue = true; + } } else { gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); + tp_failure_notification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); returnValue = true; } } + } // End of special handling for "TeleportEntryAccessBlocked" + else + { // Normal case, no message munging + gAgent.clearTeleportRequest(); + if (LLNotificationTemplates::getInstance()->templateExists(notificationID)) + { + tp_failure_notification = LLNotificationsUtil::add(notificationID, llsdBlock, llsdBlock); + } else { - gAgent.clearTeleportRequest(); - maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback); - returnValue = true; + llsdBlock["MESSAGE"] = defaultMessage; + tp_failure_notification = LLNotificationsUtil::add("GenericAlertOK", llsdBlock); } + returnValue = true; } - if ((maturityLevelNotification == NULL) || maturityLevelNotification->isIgnored()) + if ((tp_failure_notification == NULL) || tp_failure_notification->isIgnored()) { - // Given a simple notification if no maturityLevelNotification is set or it is ignore + // Given a simple notification if no tp_failure_notification is set or it is ignore LLNotificationsUtil::add(notificationID + notifySuffix, llsdBlock); } @@ -6942,8 +6957,7 @@ void chat_mean_collision(const LLUUID& id, const LLAvatarName& avname, const EMe args["ACT"] = LLTrans::getString("physical_object_collide"); else return; // How did we get here? I used to know you so well. - std::string name; - LLAvatarNameCache::getPNSName(avname, name); + const std::string name(avname.getNSName()); args["NAME"] = name; args["MAG"] = llformat("%f", mag); LLChat chat(LLTrans::getString("BumpedYou", args)); @@ -7237,6 +7251,7 @@ bool script_question_cb(const LLSD& notification, const LLSD& response) return false; } + static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb); static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb); @@ -7384,7 +7399,6 @@ void process_script_question(LLMessageSystem *msg, void **user_data) // fall back to default behavior if cautions are entirely disabled LLNotificationsUtil::add("ScriptQuestion", args, payload); } - } } @@ -7516,8 +7530,8 @@ std::string formatted_time(const time_t& the_time) void process_teleport_failed(LLMessageSystem *msg, void**) { - std::string reason; - std::string big_reason; + std::string message_id; // Tag from server, like "RegionEntryAccessBlocked" + std::string big_reason; // Actual message to display LLSD args; // Let the interested parties know that teleport failed. @@ -7527,16 +7541,16 @@ void process_teleport_failed(LLMessageSystem *msg, void**) if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0) { // Get the message ID - msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, reason); - big_reason = LLAgent::sTeleportErrorMessages[reason]; + msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, message_id); + big_reason = LLAgent::sTeleportErrorMessages[message_id]; if ( big_reason.size() > 0 ) { // Substitute verbose reason from the local map args["REASON"] = big_reason; } else { // Nothing found in the map - use what the server returned in the original message block - msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason); - args["REASON"] = reason; + msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, big_reason); + args["REASON"] = big_reason; } LLSD llsd_block; @@ -7552,7 +7566,7 @@ void process_teleport_failed(LLMessageSystem *msg, void**) else { // change notification name in this special case - if (handle_teleport_access_blocked(llsd_block)) + if (handle_teleport_access_blocked(llsd_block, message_id, args["REASON"])) { if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) { @@ -7565,17 +7579,17 @@ void process_teleport_failed(LLMessageSystem *msg, void**) } else - { - msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason); + { // Extra message payload not found - use what the simulator sent + msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, message_id); - big_reason = LLAgent::sTeleportErrorMessages[reason]; + big_reason = LLAgent::sTeleportErrorMessages[message_id]; if ( big_reason.size() > 0 ) { // Substitute verbose reason from the local map args["REASON"] = big_reason; } else { // Nothing found in the map - use what the server returned - args["REASON"] = reason; + args["REASON"] = message_id; } } @@ -7621,9 +7635,8 @@ void process_teleport_local(LLMessageSystem *msg,void**) } } - static LLCachedControl fly_after_tp(gSavedSettings, "LiruFlyAfterTeleport"); // Sim tells us whether the new position is off the ground - if (fly_after_tp || (teleport_flags & TELEPORT_FLAGS_IS_FLYING)) + if (teleport_flags & TELEPORT_FLAGS_IS_FLYING || gSavedSettings.getBOOL("LiruFlyAfterTeleport")) { gAgent.setFlying(TRUE); } @@ -7759,6 +7772,7 @@ void send_lures(const LLSD& notification, const LLSD& response) msg->nextBlockFast(_PREHASH_TargetData); msg->addUUIDFast(_PREHASH_TargetID, target_id); + // Record the offer. if (notification["payload"]["ids"].size() < 10) // Singu Note: Do NOT spam chat! { @@ -7767,14 +7781,13 @@ void send_lures(const LLSD& notification, const LLSD& response) // [/RLVa:KB] std::string target_name; gCacheName->getFullName(target_id, target_name); // for im log filenames - LLSD args; // [RLVa:KB] - Checked: 2014-03-31 (Catznip-3.6) if (fRlvHideName) target_name = RlvStrings::getAnonym(target_name); else // [/RLVa:KB] - LLAvatarNameCache::getPNSName(target_id, target_name); + LLAvatarNameCache::getNSName(target_id, target_name); args["TO_NAME"] = target_name; LLSD payload; @@ -8411,9 +8424,7 @@ void process_covenant_reply(LLMessageSystem* msg, void**) void callbackCacheEstateOwnerName(const LLUUID& id, const LLAvatarName& av_name) { - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - + const std::string name(av_name.getNSName()); LLPanelEstateCovenant::updateEstateOwnerName(name); LLPanelLandCovenant::updateEstateOwnerName(name); LLPanelEstateInfo::updateEstateOwnerName(name); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 95b24f7d7..0c094369d 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3363,10 +3363,10 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // LLFontGL::getFontSansSerifSmall()); } - // On SecondLife we can take a shortcut through getPNSName, which will strip out Resident + // On SecondLife we can take a shortcut through getNSName, which will strip out Resident if (gHippoGridManager->getConnectedGrid()->isSecondLife()) { - if (!LLAvatarNameCache::getPNSName(getID(), firstnameText)) + if (!LLAvatarNameCache::getNSName(getID(), firstnameText)) { // ...call this function back when the name arrives and force a rebuild LLAvatarNameCache::get(getID(), boost::bind(&LLVOAvatar::clearNameTag, this)); @@ -3387,7 +3387,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) bool show_display_names = phoenix_name_system > 0 || phoenix_name_system < 4; bool show_usernames = phoenix_name_system != 2; - if (show_display_names && LLAvatarNameCache::useDisplayNames()) + if (show_display_names && LLAvatarName::useDisplayNames()) { LLAvatarName av_name; if (!LLAvatarNameCache::get(getID(), &av_name)) @@ -3405,22 +3405,21 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) // Might be blank if name not available yet, that's OK if (show_display_names) { - firstnameText = phoenix_name_system == 3 ? av_name.mUsername : av_name.mDisplayName; //Defer for later formatting - //addNameTagLine(av_name.mDisplayName, name_tag_color, LLFontGL::NORMAL, + firstnameText = phoenix_name_system == 3 ? av_name.getUserName() : av_name.getDisplayName(); //Defer for later formatting + //addNameTagLine(av_name.getDisplayName(), name_tag_color, LLFontGL::NORMAL, // LLFontGL::getFontSansSerif()); } // Suppress SLID display if display name matches exactly (ugh) - if (show_usernames && !av_name.mIsDisplayNameDefault && !av_name.mUsername.empty()) + if (show_usernames && !av_name.isDisplayNameDefault()) { firstnameText.push_back(' '); firstnameText.push_back('('); - firstnameText.append(phoenix_name_system == 3 ? av_name.mDisplayName : av_name.mUsername); //Defer for later formatting + firstnameText.append(phoenix_name_system == 3 ? av_name.getDisplayName() : av_name.getAccountName()); //Defer for later formatting firstnameText.push_back(')'); // *HACK: Desaturate the color //LLColor4 username_color = name_tag_color * 0.83f; - //nameText=av_name.mUsername; - //addNameTagLine(av_name.mUsername, username_color, LLFontGL::NORMAL, - //LLFontGL::getFontSansSerifSmall()); + //addNameTagLine(av_name.getUserName(), username_color, LLFontGL::NORMAL, + // LLFontGL::getFontSansSerifSmall()); } // [RLVa:KB] - Checked: 2010-10-31 (RLVa-1.2.2a) | Modified: RLVa-1.2.2a } @@ -3707,11 +3706,11 @@ LLColor4 LLVOAvatar::getNameTagColor(bool is_friend) static const LLCachedControl avatar_name_color(gColors,"AvatarNameColor",LLColor4(LLColor4U(251, 175, 93, 255)) ); return avatar_name_color; } - /*else if (LLAvatarNameCache::useDisplayNames()) + /*else if (LLAvatarName::useDisplayNames()) { // ...color based on whether username "matches" a computed display name LLAvatarName av_name; - if (LLAvatarNameCache::get(getID(), &av_name) && av_name.mIsDisplayNameDefault) + if (LLAvatarNameCache::get(getID(), &av_name) && av_name.isDisplayNameDefault()) { color_name = "NameTagMatch"; } @@ -5637,7 +5636,7 @@ BOOL LLVOAvatar::processSingleAnimationStateChange( const LLUUID& anim_id, BOOL if (announce_snapshots) { std::string name; - LLAvatarNameCache::getPNSName(mID, name); + LLAvatarNameCache::getNSName(mID, name); LLChat chat; chat.mFromName = name; chat.mText = name + " " + LLTrans::getString("took_a_snapshot") + "."; @@ -6404,19 +6403,32 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi if (!attachment) { - llwarns << "Object attachment point invalid: " << attachmentID << llendl; + llwarns << "Object attachment point invalid: " << attachmentID + << " trying to use 1 (chest)" + << LL_ENDL; + if (isSelf() && attachmentID == 127 && gSavedSettings.getBOOL("SGDetachBridge")) { llinfos << "Bridge detected! detaching" << llendl; sDetachBridgeConnection = gAgentAvatarp->setAttachmentCallback(boost::bind(detach_bridge, _1, viewer_object)); } -// attachment = get_if_there(mAttachmentPoints, 1, (LLViewerJointAttachment*)NULL); // Arbitrary using 1 (chest) -// [SL:KB] - Patch: Appearance-LegacyMultiAttachment | Checked: 2010-08-28 (Catznip-2.2.0a) | Added: Catznip2.1.2a - S32 idxAttachPt = 1; - if ( (!isSelf()) && (gSavedSettings.getBOOL("LegacyMultiAttachmentSupport")) && (attachmentID > 38) && (attachmentID <= 68) ) - idxAttachPt = attachmentID - 38; - attachment = get_if_there(mAttachmentPoints, idxAttachPt, (LLViewerJointAttachment*)NULL); -// [/SL:KB] + attachment = get_if_there(mAttachmentPoints, 1, (LLViewerJointAttachment*)NULL); // Arbitrary using 1 (chest) + if (attachment) + { + llwarns << "Object attachment point invalid: " << attachmentID + << " on object " << viewer_object->getID() + << " attachment item " << viewer_object->getAttachmentItemID() + << " falling back to 1 (chest)" + << LL_ENDL; + } + else + { + llwarns << "Object attachment point invalid: " << attachmentID + << " on object " << viewer_object->getID() + << " attachment item " << viewer_object->getAttachmentItemID() + << "Unable to use fallback attachment point 1 (chest)" + << LL_ENDL; + } } return attachment; @@ -6500,7 +6512,7 @@ void LLVOAvatar::lazyAttach() llwarns << "attachObject() failed for " << cur_attachment->getID() << " item " << cur_attachment->getAttachmentItemID() - << llendl; + << LL_ENDL; // MAINT-3312 backout //still_pending.push_back(cur_attachment); } @@ -6805,9 +6817,6 @@ BOOL LLVOAvatar::isWearingWearableType(LLWearableType::EType type) const break; // Do nothing } - /* switch(type) - case LLWearableType::WT_SHIRT: - indicator_te = TEX_UPPER_SHIRT; */ for (LLAvatarAppearanceDictionary::Textures::const_iterator tex_iter = LLAvatarAppearanceDictionary::getInstance()->getTextures().begin(); tex_iter != LLAvatarAppearanceDictionary::getInstance()->getTextures().end(); ++tex_iter) @@ -7256,9 +7265,7 @@ void LLVOAvatar::debugColorizeSubMeshes(U32 i, const LLColor4& color) LLAvatarJointMesh* mesh = (*iter); if (mesh) { - { - mesh->setColor(color); - } + mesh->setColor(color); } } } diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 888687bd1..9fd41d8a6 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -61,9 +61,6 @@ // for base64 decoding #include "apr_base64.h" -extern AIHTTPTimeoutPolicy vivoxVoiceAccountProvisionResponder_timeout; -extern AIHTTPTimeoutPolicy vivoxVoiceClientCapResponder_timeout; - #define USE_SESSION_GROUPS 0 const F32 VOLUME_SCALE_VIVOX = 0.01f; @@ -116,17 +113,19 @@ static int scale_speaker_volume(float volume) class LLVivoxVoiceAccountProvisionResponder : public LLHTTPClient::ResponderWithResult { + LOG_CLASS(LLVivoxVoiceAccountProvisionResponder); public: LLVivoxVoiceAccountProvisionResponder(int retries) { mRetries = retries; } - /*virtual*/ void httpFailure(void) +private: + /* virtual */ void httpFailure() { LL_WARNS("Voice") << "ProvisionVoiceAccountRequest returned an error, " << ( (mRetries > 0) ? "retrying" : "too many retries (giving up)" ) - << mStatus << "]: " << mReason << LL_ENDL; + << " " << dumpResponse() << LL_ENDL; if ( mRetries > 0 ) { @@ -138,30 +137,33 @@ public: } } - /*virtual*/ void httpSuccess(void) + /* virtual */ void httpSuccess() { - std::string voice_sip_uri_hostname; std::string voice_account_server_uri; - LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << ll_pretty_print_sd(mContent) << LL_ENDL; + LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << dumpResponse() << LL_ENDL; - if(mContent.has("voice_sip_uri_hostname")) - voice_sip_uri_hostname = mContent["voice_sip_uri_hostname"].asString(); + const LLSD& content = getContent(); + if (!content.isMap()) + { + failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); + return; + } + if(content.has("voice_sip_uri_hostname")) + voice_sip_uri_hostname = content["voice_sip_uri_hostname"].asString(); // this key is actually misnamed -- it will be an entire URI, not just a hostname. - if(mContent.has("voice_account_server_name")) - voice_account_server_uri = mContent["voice_account_server_name"].asString(); + if(content.has("voice_account_server_name")) + voice_account_server_uri = content["voice_account_server_name"].asString(); LLVivoxVoiceClient::getInstance()->login( - mContent["username"].asString(), - mContent["password"].asString(), + content["username"].asString(), + content["password"].asString(), voice_sip_uri_hostname, voice_account_server_uri); - } - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return vivoxVoiceAccountProvisionResponder_timeout; } /*virtual*/ char const* getName(void) const { return "LLVivoxVoiceAccountProvisionResponder"; } private: @@ -185,37 +187,38 @@ static bool sMuteListListener_listening = false; class LLVivoxVoiceClientCapResponder : public LLHTTPClient::ResponderWithResult { + LOG_CLASS(LLVivoxVoiceClientCapResponder); public: LLVivoxVoiceClientCapResponder(LLVivoxVoiceClient::state requesting_state) : mRequestingState(requesting_state) {}; - /*virtual*/ void httpFailure(void); - /*virtual*/ void httpSuccess(void); - /*virtual*/ AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return vivoxVoiceClientCapResponder_timeout; } - /*virtual*/ char const* getName(void) const { return "LLVivoxVoiceClientCapResponder"; } - private: + // called with bad status codes + /*virtual*/ void httpFailure(); + /*virtual*/ void httpSuccess(); + /*virtual*/ char const* getName() const { return "LLVivoxVoiceClientCapResponder"; } + LLVivoxVoiceClient::state mRequestingState; // state }; -void LLVivoxVoiceClientCapResponder::httpFailure(void) +void LLVivoxVoiceClientCapResponder::httpFailure() { - LL_WARNS("Voice") << "LLVivoxVoiceClientCapResponder error [status:" - << mStatus << "]: " << mReason << LL_ENDL; + LL_WARNS("Voice") << dumpResponse() << LL_ENDL; LLVivoxVoiceClient::getInstance()->sessionTerminate(); } -void LLVivoxVoiceClientCapResponder::httpSuccess(void) +void LLVivoxVoiceClientCapResponder::httpSuccess() { LLSD::map_const_iterator iter; - LL_DEBUGS("Voice") << "ParcelVoiceInfoRequest response:" << ll_pretty_print_sd(mContent) << LL_ENDL; + LL_DEBUGS("Voice") << "ParcelVoiceInfoRequest response:" << dumpResponse() << LL_ENDL; std::string uri; std::string credentials; - if ( mContent.has("voice_credentials") ) + const LLSD& content = getContent(); + if ( content.has("voice_credentials") ) { - LLSD voice_credentials = mContent["voice_credentials"]; + LLSD voice_credentials = content["voice_credentials"]; if ( voice_credentials.has("channel_uri") ) { uri = voice_credentials["channel_uri"].asString(); @@ -819,12 +822,13 @@ void LLVivoxVoiceClient::stateMachine() // using glib first. char *voice_path = g_find_program_in_path ("SLVoice"); std::string exe_path; - if (voice_path) { + if (voice_path) + { exe_path = llformat("%s", voice_path); free(voice_path); - } else { - exe_path = gDirUtilp->getExecutableDir() + gDirUtilp->getDirDelimiter() + "SLVoice"; } + else + exe_path = gDirUtilp->getExecutableDir() + gDirUtilp->getDirDelimiter() + "SLVoice"; #else // *FIX:Mani - Using the executable dir instead // of mAppRODataDir, the working directory from which the app @@ -2817,7 +2821,7 @@ void LLVivoxVoiceClient::loginResponse(int statusCode, std::string &statusString // Status code of 20200 means "bad password". We may want to special-case that at some point. - if ( statusCode == 401 ) + if ( statusCode == HTTP_UNAUTHORIZED ) { // Login failure which is probably caused by the delay after a user's password being updated. LL_INFOS("Voice") << "Account.Login response failure (" << statusCode << "): " << statusString << LL_ENDL; @@ -3319,7 +3323,7 @@ void LLVivoxVoiceClient::mediaStreamUpdatedEvent( switch(statusCode) { case 0: - case 200: + case HTTP_OK: // generic success // Don't change the saved error code (it may have been set elsewhere) break; @@ -5565,9 +5569,10 @@ void LLVivoxVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::ESta { switch(mAudioSession->mErrorStatusCode) { - case 404: // NOT_FOUND + case HTTP_NOT_FOUND: // NOT_FOUND + // *TODO: Should this be 503? case 480: // TEMPORARILY_UNAVAILABLE - case 408: // REQUEST_TIMEOUT + case HTTP_REQUEST_TIME_OUT: // REQUEST_TIMEOUT // call failed because other user was not available // treat this as an error case status = LLVoiceClientStatusObserver::ERROR_NOT_AVAILABLE; @@ -5646,7 +5651,7 @@ void LLVivoxVoiceClient::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) { mAvatarNameCacheConnection.disconnect(); - std::string display_name = av_name.mDisplayName; + std::string display_name = av_name.getDisplayName(); avatarNameResolved(agent_id, display_name); } diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index 5ee7bfba6..3c527118d 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -398,7 +398,7 @@ void RlvUtil::filterNames(std::string& strUTF8Text, bool fFilterLegacy) LLAvatarName avName; if (LLAvatarNameCache::get(idAgents[idxAgent], &avName)) { - const std::string& strDisplayName = escape_for_regex(avName.mDisplayName); + const std::string& strDisplayName = escape_for_regex(avName.getDisplayName()); bool fFilterDisplay = (strDisplayName.length() > 2); const std::string& strLegacyName = avName.getLegacyName(); fFilterLegacy &= (strLegacyName.length() > 2); diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index a4411f146..ef7d90ea6 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -296,7 +296,7 @@ template struct RlvPredValuesEqual // Checked: 2010-10-31 (RLVa-1.2.2a) | Added: RLVa-1.2.2a inline const std::string& RlvStrings::getAnonym(const LLAvatarName& avName) { - return getAnonym(avName.mDisplayName); + return getAnonym(avName.getDisplayName()); } // Checked: 2010-03-26 (RLVa-1.2.0b) | Modified: RLVa-1.0.2a diff --git a/indra/newview/rlvfloaters.cpp b/indra/newview/rlvfloaters.cpp index d409d08ba..8c0ebe1e0 100644 --- a/indra/newview/rlvfloaters.cpp +++ b/indra/newview/rlvfloaters.cpp @@ -243,7 +243,7 @@ void RlvFloaterBehaviours::onBtnCopyToClipboard() if (gObjectList.findObject(idOption)) strOption = rlvGetItemNameFromObjID(idOption, true); else if (LLAvatarNameCache::get(idOption, &avName)) - strOption = (!avName.mUsername.empty()) ? avName.mUsername : avName.mDisplayName; + strOption = (!avName.getAccountName().empty()) ? avName.getAccountName() : avName.getDisplayName(); else if (!gCacheName->getGroupName(idOption, strOption)) strOption = itCmd->getOption(); } @@ -321,7 +321,7 @@ void RlvFloaterBehaviours::refreshAll() } else if (LLAvatarNameCache::get(idOption, &avName)) { - strOption = (!avName.mUsername.empty()) ? avName.mUsername : avName.mDisplayName; + strOption = (!avName.getAccountName().empty()) ? avName.getAccountName() : avName.getDisplayName(); } else if (!gCacheName->getGroupName(idOption, strOption)) { diff --git a/indra/newview/scriptcounter.cpp b/indra/newview/scriptcounter.cpp index f8d2aafd4..61219980b 100644 --- a/indra/newview/scriptcounter.cpp +++ b/indra/newview/scriptcounter.cpp @@ -48,9 +48,7 @@ namespace { void countedScriptsOnAvatar(LLStringUtil::format_map_t args, const LLAvatarName& av_name) { - std::string name; - LLAvatarNameCache::getPNSName(av_name, name); - args["NAME"] = name; + args["NAME"] = av_name.getNSName(); cmdline_printchat(LLTrans::getString("ScriptCountAvatar", args)); } } diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index f026201f5..cfe7b479a 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -441,6 +441,7 @@ There is no marketplace on the region you've moved to. name="CompileQueueSaveText" type="alertmodal"> There was a problem uploading the text for a script due to the following reason: [REASON]. Please try again later. + fail There was a problem uploading the compiled script due to the following reason: [REASON]. Please try again later. + fail There was a problem writing animation data. Please try again later. + fail There was a problem uploading the auction snapshot due to the following reason: [REASON] + fail Unable to view the contents of more than one item at a time. Please select only one object and try again. + fail Save all changes to clothing/body parts? +confirm Granting modify rights to another Resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission. Do you want to grant modify rights for [NAME]? +confirm Granting modify rights to another Resident allows them to change ANY objects you may have in-world. Be VERY careful when handing out this permission. Do you want to grant modify rights for the selected Residents? +confirm Do you want to revoke modify rights for [NAME]? +confirm Do you want to revoke modify rights for the selected Residents? +confirm Unable to create group. [MESSAGE] + group + fail @@ -554,6 +566,8 @@ Unable to create group. type="alertmodal"> [NEEDS_APPLY_MESSAGE] [WANT_APPLY_MESSAGE] + confirm + group You must specify a subject to send a group notice. + group + fail @@ -579,8 +595,10 @@ You are about to add group members to the role of [ROLE_NAME]. Members cannot be removed from that role. The members must resign from the role themselves. Are you sure you want to continue? + group + confirm @@ -911,6 +929,7 @@ For information about this feature, click "More Info". Are you sure you want to return all objects owned by you on this parcel of land back to your inventory? Objects: [N] + confirm confirm confirm Are you sure you want to return all listed objects back to their owner's inventory? + confirm Are you sure you want to disable all objects in this region? + confirm confirm + group fail + You must be standing inside the land parcel to set its Landing Point. + fail Please enter a valid email address for the recipient(s). + fail Please enter your email address. + fail Email snapshot with the default subject or message? + confirm Error processing snapshot data + fail Error encoding snapshot. + fail There was a problem sending a snapshot due to the following reason: [REASON] + fail There was a problem uploading a report screenshot due to the following reason: [REASON] + fail + fail You must agree to the Terms of Service to continue logging into [SECOND_LIFE]. @@ -1088,6 +1124,7 @@ You must agree to the Terms of Service to continue logging into [SECOND_LIFE]. type="alertmodal"> Could not put on outfit. The outfit folder contains no clothing, body parts, or attachments. + fail You can not wear clothes or body parts that are in the trash + fail Could not attach object. Exceeds the attachments limit of [MAX_ATTACHMENTS] objects. Please detach another object first. + fail You can not wear that item because it has not yet loaded. Please try again in a minute. + fail + fail Oops! Something was left blank. You need to enter the Username name of your avatar. @@ -1156,6 +1197,7 @@ Paying more makes your ad appear higher in the list, and also appear higher when type="alertmodal"> Delete classified '[NAME]'? There is no reimbursement for fees paid. + confirm Save changes to classified [NAME]? + confirm Please select a proposal to view. + fail Please select a history item to view. + fail Could not save notecard because the object or the associated object inventory could not be found. The object may be out of range or may have been deleted. +fail There was a problem saving a notecard due to the following reason: [REASON]. Please try re-saving the notecard later. +fail confirm There was a problem saving a script due to the following reason: [REASON]. Please try re-saving the script later. +fail Could not save the script because the object it is in could not be found. The object may be out of range or may have been deleted. +fail There was a problem saving a compiled script due to the following reason: [REASON]. Please try re-saving the script later. + +fail Could not start or stop the script because the object it is on could not be found. The object may be out of range or may have been deleted. + fail Unable to download file + fail Unable to write file [[FILE]] + fail + fail + + fail [APP_NAME] crashed while initializing graphics drivers. - Graphics Quality will be set to low to avoid some common driver errors. + Graphics Quality will be set to Low to avoid some common driver errors. This will disable some graphics features. We recommend updating your graphics card drivers. Graphics Quality can be raised in Preferences > Graphics. + fail The region [REGION] does not allow terraforming. + fail confirm + fail Unable to give inventory item. + fail Cannot give more than 42 items in a single inventory transfer. + fail You do not have permission to transfer the selected items. + fail You do not have permission to copy [COUNT] of the selected items. You will lose these items from your inventory. Do you really want to give these items? + confirm + fail You do not have permission to transfer the selected folder. + fail Freeze this avatar? He or she will temporarily be unable to move, chat, or interact with the world. + confirm Freeze [AVATAR_NAME]? He or she will temporarily be unable to move, chat, or interact with the world. + confirm Eject [AVATAR_NAME] from your land? + confirm Eject this avatar from your land? + confirm Eject [AVATAR_NAME] from your land? + confirm ACQUIRE ERROR: Too many objects selected. + fail ACQUIRE ERROR: Objects span more than one region. Please move all objects to be acquired onto the same region. + fail Unable to link these [COUNT] objects. You can link a maximum of [MAX] objects. + fail You can only link complete sets of objects, and must select more than one object. + fail fail Objects cannot be linked across region boundaries. + fail fail fail + fail Couldn't open uploaded sound file for reading: [FILE] + fail File does not appear to be a RIFF WAVE file: [FILE] + fail File does not appear to be a PCM WAVE audio file: [FILE] + fail File has invalid number of channels (must be mono or stereo): [FILE] + fail File does not appear to be a supported sample rate (must be 44.1k): [FILE] + fail File does not appear to be a supported word size (must be 8 or 16 bit): [FILE] + fail Could not find 'data' chunk in WAV header: [FILE] + fail Wrong chunk size in WAV file: [FILE] + fail Audio file is too long (10 second maximum): [FILE] + fail fail Couldn't open temporary compressed sound file for writing: [FILE] + fail Unknown Vorbis encode failure on: [FILE] + fail Unable to encode file: [FILE] + fail Corrupt resource file: [FILE] + fail Unknown resource file version in file: [FILE] + fail Unable to create output file: [FILE] + fail We do not currently support bulk upload of BVH animation files. + fail Unable to upload [FILE] due to the following reason: [REASON] Please try again later. + fail You cannot create a landmark here because the owner of the land doesn't allow it. + fail Not able to perform 'recompilation'. Select an object with a script. + fail fail fail fail fail fail No frontmost floater to save. + fail Your search terms were too short so no search was performed. + fail @@ -3621,6 +3872,7 @@ Sorry, you have to wait longer before you can change your display name. See http://wiki.secondlife.com/wiki/Setting_your_display_name Please try again later. + fail fail The display name you wish to set contains invalid characters. + fail Your display name must contain letters other than punctuation. + fail + Offer a teleport to your location with the following message? + confirm
Join me in [REGION] @@ -3713,6 +3970,7 @@ which exceeds the limit of [LIMIT]. name="OfferTeleportFromGod" type="alertmodal"> God summon Resident to your location? + confirm Join me in [REGION] @@ -3759,6 +4017,7 @@ Are you sure you want to teleport to [LOCATION]? name="MessageEstate" type="alert"> Type a short announcement which will be sent to everyone currently in your estate. + confirm