LLHTTPNode* LLHTTPNode::Impl::findNamedChild(const std::string& name) const { LLHTTPNode* child = get_ptr_in_map(mNamedChildren, name); if (!child && ((name[0] == '*') || (name == mWildcardName))) { child = mWildcardChild; } return child; }
void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup) { // You should only get this message if the cache is at the simulator // level, hence having an upstream provider. if (!mUpstreamHost.isOk()) { llwarns << "LLCacheName - got UUID name/group request, but no upstream provider!" << llendl; return; } LLHost fromHost = msg->getSender(); ReplySender sender(msg); S32 count = msg->getNumberOfBlocksFast(_PREHASH_UUIDNameBlock); for(S32 i = 0; i < count; ++i) { LLUUID id; msg->getUUIDFast(_PREHASH_UUIDNameBlock, _PREHASH_ID, id, i); LLCacheNameEntry* entry = get_ptr_in_map(mCache, id); if(entry) { if (isGroup != entry->mIsGroup) { llwarns << "LLCacheName - Asked for " << (isGroup ? "group" : "user") << " name, " << "but found " << (entry->mIsGroup ? "group" : "user") << ": " << id << llendl; } else { // ...it's in the cache, so send it as the reply sender.send(id, *entry, fromHost); } } else { if (!isRequestPending(id)) { if (isGroup) { mAskGroupQueue.insert(id); } else { mAskNameQueue.insert(id); } } addPending(id, fromHost); } } }
// <edit> bool LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_group) { if (id.notNull()) if (LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id)) { fullname = (is_group = entry->mIsGroup) ? entry->mGroupName : entry->mFirstName + " " + entry->mLastName; return true; } fullname = ""; return false; }
void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data) { LLUUID session_id = data["session_id"].asUUID(); LLFloater* floaterp = get_ptr_in_map(mSessions, session_id); LLFloater* current_floater = LLMultiFloater::getActiveFloater(); if(floaterp && current_floater && floaterp != current_floater) { if(LLMultiFloater::isFloaterFlashing(floaterp)) LLMultiFloater::setFloaterFlashing(floaterp, FALSE); LLMultiFloater::setFloaterFlashing(floaterp, TRUE); } }
void FSFloaterIMContainer::onNewMessageReceived(const LLSD& data) { LLUUID session_id = data["session_id"].asUUID(); LLFloater* floaterp = get_ptr_in_map(mSessions, session_id); LLFloater* current_floater = LLMultiFloater::getActiveFloater(); // KC: Don't flash tab on friend status changes per setting if (floaterp && current_floater && floaterp != current_floater && (gSavedSettings.getBOOL("FSIMChatFlashOnFriendStatusChange") || data["from_id"].asUUID() != LLUUID::null)) { if(LLMultiFloater::isFloaterFlashing(floaterp)) LLMultiFloater::setFloaterFlashing(floaterp, FALSE); LLMultiFloater::setFloaterFlashing(floaterp, TRUE); } }
// This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior // doesn't get lost. As a result, we have to bind the slot to a signal to call it, even when // we call it immediately. -Steve // NOTE: Even though passing first and last name is a bit of extra overhead, it eliminates the // potential need for any parsing should any code need to handle first and last name independently. boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback) { boost::signals2::connection res; if(id.isNull()) { LLCacheNameSignal signal; signal.connect(callback); signal(id, sCacheName["nobody"], is_group); return res; } LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); if (entry) { LLCacheNameSignal signal; signal.connect(callback); // id found in map therefore we can call the callback immediately. if (entry->mIsGroup) { signal(id, entry->mGroupName, entry->mIsGroup); } else { std::string fullname = buildFullName(entry->mFirstName, entry->mLastName); signal(id, fullname, entry->mIsGroup); } } else { // id not found in map so we must queue the callback call until available. if (!impl.isRequestPending(id)) { if (is_group) { impl.mAskGroupQueue.insert(id); } else { impl.mAskNameQueue.insert(id); } } res = impl.addPending(id, callback); } return res; }
// virtual LLHTTPNode* LLHTTPNode::getChild(const std::string& name, LLSD& context) const { LLHTTPNode* namedChild = get_ptr_in_map(impl.mNamedChildren, name); if (namedChild) { return namedChild; } if (impl.mWildcardChild && impl.mWildcardChild->validate(name, context)) { context[CONTEXT_REQUEST][CONTEXT_WILDCARD][impl.mWildcardKey] = name; return impl.mWildcardChild; } return NULL; }
LLLandmark* LLLandmarkList::getAsset(const LLUUID& asset_uuid, loaded_callback_t cb) { LLLandmark* landmark = get_ptr_in_map(mList, asset_uuid); if(landmark) { LLVector3d dummy; if(cb && !landmark->getGlobalPos(dummy)) { // landmark is not completely loaded yet loaded_callback_map_t::value_type vt(asset_uuid, cb); mLoadedCallbackMap.insert(vt); } return landmark; } else { if ( mBadList.find(asset_uuid) != mBadList.end() ) { return NULL; } landmark_requested_list_t::iterator iter = mRequestedList.find(asset_uuid); if (iter != mRequestedList.end()) { const F32 rerequest_time = 30.f; // 30 seconds between requests if (gFrameTimeSeconds - iter->second < rerequest_time) { return NULL; } } if (cb) { loaded_callback_map_t::value_type vt(asset_uuid, cb); mLoadedCallbackMap.insert(vt); } gAssetStorage->getAssetData(asset_uuid, LLAssetType::AT_LANDMARK, LLLandmarkList::processGetAssetReply, NULL); mRequestedList[asset_uuid] = gFrameTimeSeconds; } return NULL; }
LLLandmark* LLLandmarkList::getAsset( const LLUUID& asset_uuid ) { LLLandmark* landmark = get_ptr_in_map(mList, asset_uuid); if(landmark) { return landmark; } else { if ( gLandmarkList.mBadList.find(asset_uuid) == gLandmarkList.mBadList.end() ) { gAssetStorage->getAssetData( asset_uuid, LLAssetType::AT_LANDMARK, LLLandmarkList::processGetAssetReply, NULL); } } return NULL; }
void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) { S32 count = msg->getNumberOfBlocksFast(_PREHASH_UUIDNameBlock); for(S32 i = 0; i < count; ++i) { LLUUID id; msg->getUUIDFast(_PREHASH_UUIDNameBlock, _PREHASH_ID, id, i); LLCacheNameEntry* entry = get_ptr_in_map(mCache, id); if (!entry) { entry = new LLCacheNameEntry; mCache[id] = entry; } mPendingQueue.erase(id); entry->mIsGroup = isGroup; entry->mCreateTime = (U32)time(NULL); if (!isGroup) { msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_FirstName, entry->mFirstName, i); msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_LastName, entry->mLastName, i); } else { // is group msg->getStringFast(_PREHASH_UUIDNameBlock, _PREHASH_GroupName, entry->mGroupName, i); LLStringFn::replace_ascii_controlchars(entry->mGroupName, LL_UNKNOWN_CHAR); } if (!isGroup) { notifyObservers(id, entry->mFirstName, entry->mLastName, FALSE); } else { notifyObservers(id, entry->mGroupName, "", TRUE); } } }
// TODO: Make the cache name callback take a SINGLE std::string, // not a separate first and last name. void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) { if(id.isNull()) { callback(id, CN_NOBODY, "", is_group, user_data); return; } LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); if (entry) { // id found in map therefore we can call the callback immediately. if (entry->mIsGroup) { callback(id, entry->mGroupName, "", entry->mIsGroup, user_data); } else { callback(id, entry->mFirstName, entry->mLastName, entry->mIsGroup, user_data); } } else { // id not found in map so we must queue the callback call until available. if (!impl.isRequestPending(id)) { if (is_group) { impl.mAskGroupQueue.insert(id); } else { impl.mAskNameQueue.insert(id); } } impl.mReplyQueue.push_back(PendingReply(id, callback, user_data)); } }
// Returns template for the message contained in buffer BOOL LLTemplateMessageReader::decodeTemplate( const U8* buffer, S32 buffer_size, // inputs LLMessageTemplate** msg_template ) // outputs { const U8* header = buffer + LL_PACKET_ID_SIZE; // is there a message ready to go? if (buffer_size <= 0) { llwarns << "No message waiting for decode!" << llendl; return(FALSE); } U32 num = 0; if (header[0] != 255) { // high frequency message num = header[0]; } else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 1)) && (header[1] != 255)) { // medium frequency message num = (255 << 8) | header[1]; } else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 3)) && (header[1] == 255)) { // low frequency message U16 message_id_U16 = 0; // I think this check busts the message system. // it appears that if there is a NULL in the message #, it won't copy it.... // what was the goal? //if(header[2]) memcpy(&message_id_U16, &header[2], 2); // dependant on endian-ness: // U32 temp = (255 << 24) | (255 << 16) | header[2]; // independant of endian-ness: message_id_U16 = ntohs(message_id_U16); num = 0xFFFF0000 | message_id_U16; } else // bogus packet received (too short) { llwarns << "Packet with unusable length received (too short): " << buffer_size << llendl; return(FALSE); } LLMessageTemplate* temp = get_ptr_in_map(mMessageNumbers,num); if (temp) { *msg_template = temp; } else { llwarns << "Message #" << std::hex << num << std::dec << " received but not registered!" << llendl; gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE); return(FALSE); } return(TRUE); }