From 117e22047c5752352342d64e3fb7ce00a4eb8113 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:04 -0500 Subject: Second Life viewer sources 1.18.1.2 --- linden/indra/newview/llviewermessage.cpp | 98 ++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 44 deletions(-) (limited to 'linden/indra/newview/llviewermessage.cpp') diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index d45cf34..6bca17e 100644 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -63,6 +63,7 @@ #include "message.h" #include "sound_ids.h" #include "lltimer.h" +#include "llmd5.h" #include "llagent.h" #include "llcallingcard.h" @@ -70,6 +71,7 @@ #include "llviewercontrol.h" #include "lldrawpool.h" #include "llfirstuse.h" +#include "llfloateractivespeakers.h" #include "llfloaterbuycurrency.h" #include "llfloaterbuyland.h" #include "llfloaterchat.h" @@ -341,10 +343,15 @@ void export_complete() FILE* fXML = LLFile::fopen(gExportedFile.c_str(), "rb"); /* Flawfinder: ignore */ fseek(fXML, 0, SEEK_END); - U32 length = ftell(fXML); + long length = ftell(fXML); fseek(fXML, 0, SEEK_SET); - U8 *buffer = new U8[length]; - fread(buffer, 1, length, fXML); + U8 *buffer = new U8[length + 1]; + size_t nread = fread(buffer, 1, length, fXML); + if (nread < (size_t) length) + { + llwarns << "Short read" << llendl; + } + buffer[nread] = '\0'; fclose(fXML); char *pos = (char *)buffer; @@ -380,7 +387,10 @@ void export_complete() } FILE* fXMLOut = LLFile::fopen(gExportedFile.c_str(), "wb"); /* Flawfinder: ignore */ - fwrite(buffer, 1, length, fXMLOut); + if (fwrite(buffer, 1, length, fXMLOut) != length) + { + llwarns << "Short write" << llendl; + } fclose(fXMLOut); delete [] buffer; @@ -442,7 +452,10 @@ void exported_j2c_complete(const LLTSCode status, void *user_data) S32 length = ftell(fIn); fseek(fIn, 0, SEEK_SET); U8 *buffer = ImageUtility->allocateData(length); - fread(buffer, 1, length, fIn); + if (fread(buffer, 1, length, fIn) != length) + { + llwarns << "Short read" << llendl; + } fclose(fIn); LLFile::remove(filename.c_str()); @@ -469,7 +482,10 @@ void exported_j2c_complete(const LLTSCode status, void *user_data) strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */ if (fOut) { - fwrite(data, 1, data_size, fOut); + if (fwrite(data, 1, data_size, fOut) != data_size) + { + llwarns << "Short write" << llendl; + } fseek(fOut, 0, SEEK_SET); fclose(fOut); fOut = LLFile::fopen(output_file.c_str(), "rb"); /* Flawfinder: ignore */ @@ -1322,7 +1338,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) time_t timestamp = (time_t)t; BOOL is_busy = gAgent.getBusy(); - BOOL is_muted = gMuteListp->isMuted(from_id, name); + BOOL is_muted = gMuteListp->isMuted(from_id, name, LLMute::flagTextChat); BOOL is_linden = gMuteListp->isLinden(name); BOOL is_owned_by_me = FALSE; @@ -1373,7 +1389,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { // return a standard "busy" message, but only do it to online IM // (i.e. not other auto responses and not store-and-forward IM) - if (!gIMView->hasSession(session_id)) + if (!gIMMgr->hasSession(session_id)) { // if there is not a panel for this conversation (i.e. it is a new IM conversation // initiated by the other party) then... @@ -1398,14 +1414,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) snprintf(buffer, sizeof(buffer), "%s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */ - if(from_id == gAgentID) - { - from_id = LLUUID::null; - } llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl; // add to IM panel, but do not bother the user - gIMView->addMessage( + gIMMgr->addMessage( session_id, from_id, name, @@ -1455,15 +1467,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) formatted_time(timestamp, time_buf)); } snprintf(buffer, sizeof(buffer), "%s%s%s%s", name, separator_string, saved,(message+message_offset)); /* Flawfinder: ignore */ - if(from_id == gAgentID) - { - from_id = LLUUID::null; - } + llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl; if (!is_muted || is_linden) { - gIMView->addMessage( + gIMMgr->addMessage( session_id, from_id, name, @@ -1494,14 +1503,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_TYPING_START: { LLPointer im_info = new LLIMInfo(gMessageSystem); - gIMView->processIMTypingStart(im_info); + gIMMgr->processIMTypingStart(im_info); } break; case IM_TYPING_STOP: { LLPointer im_info = new LLIMInfo(gMessageSystem); - gIMView->processIMTypingStop(im_info); + gIMMgr->processIMTypingStop(im_info); } break; @@ -1734,12 +1743,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) return; } - // System messages, specifically "Foo Bar has left this session" - // are not shown unless you actually have that session open. - // Band-aid. JC - if (offline == IM_ONLINE - && chat.mFromName == SYSTEM_FROM - && !gIMView->hasSession(session_id)) + // Only show messages if we have a session open (which + // should happen after you get an "invitation" + if ( !gIMMgr->hasSession(session_id) ) { return; } @@ -1759,10 +1765,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) BOOL is_this_agent = FALSE; if(from_id == gAgentID) { - from_id = LLUUID::null; is_this_agent = TRUE; } - gIMView->addMessage( + gIMMgr->addMessage( session_id, from_id, name, @@ -1813,7 +1818,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else { // original code resumes - gIMView->addMessage(session_id, from_id, name, message); + gIMMgr->addMessage(session_id, from_id, name, message); } break; @@ -2079,7 +2084,7 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) if(!source_name.empty()) { if (gAgent.getBusy() - || gMuteListp->isMuted(source_id, source_name)) + || gMuteListp->isMuted(source_id, source_name, LLMute::flagTextChat)) { // automatically decline offer callingcard_offer_callback(1, (void*)offerdata); @@ -2155,7 +2160,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) BOOL is_linden = FALSE; if (gMuteListp) { - is_muted = gMuteListp->isMuted(from_id, from_name) + is_muted = gMuteListp->isMuted(from_id, from_name, LLMute::flagTextChat) || gMuteListp->isMuted(owner_id); is_linden = gMuteListp->isLinden(from_name); } @@ -2179,16 +2184,15 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) gWorldPointer->mPartSim.addPartSource(psc); } - // only pay attention to other people chatting + // record last audible utterance if (is_audible - && (is_linden || (!is_muted && !is_busy)) - && chatter != gAgent.getAvatarObject()) + && (is_linden || (!is_muted && !is_busy))) { - gAgent.heardChat(chat); - if (ll_rand(2) == 0) + if (chat.mChatType != CHAT_TYPE_START + && chat.mChatType != CHAT_TYPE_STOP) { - gAgent.setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero); - } + gAgent.heardChat(chat.mFromID); + } } is_owned_by_me = chatter->permYouOwner(); @@ -2219,6 +2223,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) // Look for the start of typing so we can put "..." in the bubbles. if (CHAT_TYPE_START == chat.mChatType) { + gLocalSpeakerMgr->setSpeakerTyping(from_id, TRUE); + // Might not have the avatar constructed yet, eg on login. if (chatter && chatter->isAvatar()) { @@ -2228,6 +2234,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) } else if (CHAT_TYPE_STOP == chat.mChatType) { + gLocalSpeakerMgr->setSpeakerTyping(from_id, FALSE); + // Might not have the avatar constructed yet, eg on login. if (chatter && chatter->isAvatar()) { @@ -2239,6 +2247,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) // We have a real utterance now, so can stop showing "..." and proceed. if (chatter && chatter->isAvatar()) { + gLocalSpeakerMgr->setSpeakerTyping(from_id, FALSE); ((LLVOAvatar*)chatter)->stopTyping(); if (!is_muted && !is_busy) @@ -2367,7 +2376,7 @@ void process_teleport_start(LLMessageSystem *msg, void**) gTeleportDisplay = TRUE; gAgent.setTeleportState( LLAgent::TELEPORT_START ); make_ui_sound("UISndTeleportOut"); - + // Don't call LLFirstUse::useTeleport here because this could be // due to being killed, which would send you home, not to a Telehub } @@ -2748,7 +2757,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) { avatarp->mFootPlane.clearVec(); } - + // reset always run status msg->newMessageFast(_PREHASH_SetAlwaysRun); msg->nextBlockFast(_PREHASH_AgentData); @@ -3212,7 +3221,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **) if (!gParcelMgr->canHearSound(pos_global)) return; // Don't play sounds triggered by someone you muted. - if (gMuteListp->isMuted(owner_id)) return; + if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return; // Don't play sounds from an object you muted if (gMuteListp->isMuted(object_id)) return; @@ -3224,7 +3233,8 @@ void process_sound_trigger(LLMessageSystem *msg, void **) return; } - gAudiop->triggerSound(sound_id, owner_id, gain, pos_global); + F32 volume = gain * gSavedSettings.getF32("AudioLevelSFX"); + gAudiop->triggerSound(sound_id, owner_id, volume, pos_global); } void process_preload_sound(LLMessageSystem *msg, void **user_data) @@ -3246,7 +3256,7 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data) if (!objectp) return; if (gMuteListp->isMuted(object_id)) return; - if (gMuteListp->isMuted(owner_id)) return; + if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return; LLAudioSource *sourcep = objectp->getAudioSource(owner_id); if (!sourcep) return; @@ -3284,7 +3294,7 @@ void process_attached_sound(LLMessageSystem *msg, void **user_data) if (gMuteListp->isMuted(object_id)) return; - if (gMuteListp->isMuted(owner_id)) return; + if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return; objectp->setAttachedSound(sound_id, owner_id, gain, flags); } -- cgit v1.1