aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewermessage.cpp')
-rw-r--r--linden/indra/newview/llviewermessage.cpp98
1 files changed, 54 insertions, 44 deletions
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 @@
63#include "message.h" 63#include "message.h"
64#include "sound_ids.h" 64#include "sound_ids.h"
65#include "lltimer.h" 65#include "lltimer.h"
66#include "llmd5.h"
66 67
67#include "llagent.h" 68#include "llagent.h"
68#include "llcallingcard.h" 69#include "llcallingcard.h"
@@ -70,6 +71,7 @@
70#include "llviewercontrol.h" 71#include "llviewercontrol.h"
71#include "lldrawpool.h" 72#include "lldrawpool.h"
72#include "llfirstuse.h" 73#include "llfirstuse.h"
74#include "llfloateractivespeakers.h"
73#include "llfloaterbuycurrency.h" 75#include "llfloaterbuycurrency.h"
74#include "llfloaterbuyland.h" 76#include "llfloaterbuyland.h"
75#include "llfloaterchat.h" 77#include "llfloaterchat.h"
@@ -341,10 +343,15 @@ void export_complete()
341 343
342 FILE* fXML = LLFile::fopen(gExportedFile.c_str(), "rb"); /* Flawfinder: ignore */ 344 FILE* fXML = LLFile::fopen(gExportedFile.c_str(), "rb"); /* Flawfinder: ignore */
343 fseek(fXML, 0, SEEK_END); 345 fseek(fXML, 0, SEEK_END);
344 U32 length = ftell(fXML); 346 long length = ftell(fXML);
345 fseek(fXML, 0, SEEK_SET); 347 fseek(fXML, 0, SEEK_SET);
346 U8 *buffer = new U8[length]; 348 U8 *buffer = new U8[length + 1];
347 fread(buffer, 1, length, fXML); 349 size_t nread = fread(buffer, 1, length, fXML);
350 if (nread < (size_t) length)
351 {
352 llwarns << "Short read" << llendl;
353 }
354 buffer[nread] = '\0';
348 fclose(fXML); 355 fclose(fXML);
349 356
350 char *pos = (char *)buffer; 357 char *pos = (char *)buffer;
@@ -380,7 +387,10 @@ void export_complete()
380 } 387 }
381 388
382 FILE* fXMLOut = LLFile::fopen(gExportedFile.c_str(), "wb"); /* Flawfinder: ignore */ 389 FILE* fXMLOut = LLFile::fopen(gExportedFile.c_str(), "wb"); /* Flawfinder: ignore */
383 fwrite(buffer, 1, length, fXMLOut); 390 if (fwrite(buffer, 1, length, fXMLOut) != length)
391 {
392 llwarns << "Short write" << llendl;
393 }
384 fclose(fXMLOut); 394 fclose(fXMLOut);
385 395
386 delete [] buffer; 396 delete [] buffer;
@@ -442,7 +452,10 @@ void exported_j2c_complete(const LLTSCode status, void *user_data)
442 S32 length = ftell(fIn); 452 S32 length = ftell(fIn);
443 fseek(fIn, 0, SEEK_SET); 453 fseek(fIn, 0, SEEK_SET);
444 U8 *buffer = ImageUtility->allocateData(length); 454 U8 *buffer = ImageUtility->allocateData(length);
445 fread(buffer, 1, length, fIn); 455 if (fread(buffer, 1, length, fIn) != length)
456 {
457 llwarns << "Short read" << llendl;
458 }
446 fclose(fIn); 459 fclose(fIn);
447 LLFile::remove(filename.c_str()); 460 LLFile::remove(filename.c_str());
448 461
@@ -469,7 +482,10 @@ void exported_j2c_complete(const LLTSCode status, void *user_data)
469 strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */ 482 strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */
470 if (fOut) 483 if (fOut)
471 { 484 {
472 fwrite(data, 1, data_size, fOut); 485 if (fwrite(data, 1, data_size, fOut) != data_size)
486 {
487 llwarns << "Short write" << llendl;
488 }
473 fseek(fOut, 0, SEEK_SET); 489 fseek(fOut, 0, SEEK_SET);
474 fclose(fOut); 490 fclose(fOut);
475 fOut = LLFile::fopen(output_file.c_str(), "rb"); /* Flawfinder: ignore */ 491 fOut = LLFile::fopen(output_file.c_str(), "rb"); /* Flawfinder: ignore */
@@ -1322,7 +1338,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1322 time_t timestamp = (time_t)t; 1338 time_t timestamp = (time_t)t;
1323 1339
1324 BOOL is_busy = gAgent.getBusy(); 1340 BOOL is_busy = gAgent.getBusy();
1325 BOOL is_muted = gMuteListp->isMuted(from_id, name); 1341 BOOL is_muted = gMuteListp->isMuted(from_id, name, LLMute::flagTextChat);
1326 BOOL is_linden = gMuteListp->isLinden(name); 1342 BOOL is_linden = gMuteListp->isLinden(name);
1327 BOOL is_owned_by_me = FALSE; 1343 BOOL is_owned_by_me = FALSE;
1328 1344
@@ -1373,7 +1389,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1373 { 1389 {
1374 // return a standard "busy" message, but only do it to online IM 1390 // return a standard "busy" message, but only do it to online IM
1375 // (i.e. not other auto responses and not store-and-forward IM) 1391 // (i.e. not other auto responses and not store-and-forward IM)
1376 if (!gIMView->hasSession(session_id)) 1392 if (!gIMMgr->hasSession(session_id))
1377 { 1393 {
1378 // if there is not a panel for this conversation (i.e. it is a new IM conversation 1394 // if there is not a panel for this conversation (i.e. it is a new IM conversation
1379 // initiated by the other party) then... 1395 // initiated by the other party) then...
@@ -1398,14 +1414,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1398 1414
1399 snprintf(buffer, sizeof(buffer), "%s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */ 1415 snprintf(buffer, sizeof(buffer), "%s%s%s", name, separator_string, (message+message_offset)); /* Flawfinder: ignore */
1400 1416
1401 if(from_id == gAgentID)
1402 {
1403 from_id = LLUUID::null;
1404 }
1405 llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl; 1417 llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl;
1406 1418
1407 // add to IM panel, but do not bother the user 1419 // add to IM panel, but do not bother the user
1408 gIMView->addMessage( 1420 gIMMgr->addMessage(
1409 session_id, 1421 session_id,
1410 from_id, 1422 from_id,
1411 name, 1423 name,
@@ -1455,15 +1467,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1455 formatted_time(timestamp, time_buf)); 1467 formatted_time(timestamp, time_buf));
1456 } 1468 }
1457 snprintf(buffer, sizeof(buffer), "%s%s%s%s", name, separator_string, saved,(message+message_offset)); /* Flawfinder: ignore */ 1469 snprintf(buffer, sizeof(buffer), "%s%s%s%s", name, separator_string, saved,(message+message_offset)); /* Flawfinder: ignore */
1458 if(from_id == gAgentID) 1470
1459 {
1460 from_id = LLUUID::null;
1461 }
1462 llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl; 1471 llinfos << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << llendl;
1463 1472
1464 if (!is_muted || is_linden) 1473 if (!is_muted || is_linden)
1465 { 1474 {
1466 gIMView->addMessage( 1475 gIMMgr->addMessage(
1467 session_id, 1476 session_id,
1468 from_id, 1477 from_id,
1469 name, 1478 name,
@@ -1494,14 +1503,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1494 case IM_TYPING_START: 1503 case IM_TYPING_START:
1495 { 1504 {
1496 LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem); 1505 LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem);
1497 gIMView->processIMTypingStart(im_info); 1506 gIMMgr->processIMTypingStart(im_info);
1498 } 1507 }
1499 break; 1508 break;
1500 1509
1501 case IM_TYPING_STOP: 1510 case IM_TYPING_STOP:
1502 { 1511 {
1503 LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem); 1512 LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem);
1504 gIMView->processIMTypingStop(im_info); 1513 gIMMgr->processIMTypingStop(im_info);
1505 } 1514 }
1506 break; 1515 break;
1507 1516
@@ -1734,12 +1743,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1734 return; 1743 return;
1735 } 1744 }
1736 1745
1737 // System messages, specifically "Foo Bar has left this session" 1746 // Only show messages if we have a session open (which
1738 // are not shown unless you actually have that session open. 1747 // should happen after you get an "invitation"
1739 // Band-aid. JC 1748 if ( !gIMMgr->hasSession(session_id) )
1740 if (offline == IM_ONLINE
1741 && chat.mFromName == SYSTEM_FROM
1742 && !gIMView->hasSession(session_id))
1743 { 1749 {
1744 return; 1750 return;
1745 } 1751 }
@@ -1759,10 +1765,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1759 BOOL is_this_agent = FALSE; 1765 BOOL is_this_agent = FALSE;
1760 if(from_id == gAgentID) 1766 if(from_id == gAgentID)
1761 { 1767 {
1762 from_id = LLUUID::null;
1763 is_this_agent = TRUE; 1768 is_this_agent = TRUE;
1764 } 1769 }
1765 gIMView->addMessage( 1770 gIMMgr->addMessage(
1766 session_id, 1771 session_id,
1767 from_id, 1772 from_id,
1768 name, 1773 name,
@@ -1813,7 +1818,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
1813 else 1818 else
1814 { 1819 {
1815 // original code resumes 1820 // original code resumes
1816 gIMView->addMessage(session_id, from_id, name, message); 1821 gIMMgr->addMessage(session_id, from_id, name, message);
1817 } 1822 }
1818 break; 1823 break;
1819 1824
@@ -2079,7 +2084,7 @@ void process_offer_callingcard(LLMessageSystem* msg, void**)
2079 if(!source_name.empty()) 2084 if(!source_name.empty())
2080 { 2085 {
2081 if (gAgent.getBusy() 2086 if (gAgent.getBusy()
2082 || gMuteListp->isMuted(source_id, source_name)) 2087 || gMuteListp->isMuted(source_id, source_name, LLMute::flagTextChat))
2083 { 2088 {
2084 // automatically decline offer 2089 // automatically decline offer
2085 callingcard_offer_callback(1, (void*)offerdata); 2090 callingcard_offer_callback(1, (void*)offerdata);
@@ -2155,7 +2160,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2155 BOOL is_linden = FALSE; 2160 BOOL is_linden = FALSE;
2156 if (gMuteListp) 2161 if (gMuteListp)
2157 { 2162 {
2158 is_muted = gMuteListp->isMuted(from_id, from_name) 2163 is_muted = gMuteListp->isMuted(from_id, from_name, LLMute::flagTextChat)
2159 || gMuteListp->isMuted(owner_id); 2164 || gMuteListp->isMuted(owner_id);
2160 is_linden = gMuteListp->isLinden(from_name); 2165 is_linden = gMuteListp->isLinden(from_name);
2161 } 2166 }
@@ -2179,16 +2184,15 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2179 gWorldPointer->mPartSim.addPartSource(psc); 2184 gWorldPointer->mPartSim.addPartSource(psc);
2180 } 2185 }
2181 2186
2182 // only pay attention to other people chatting 2187 // record last audible utterance
2183 if (is_audible 2188 if (is_audible
2184 && (is_linden || (!is_muted && !is_busy)) 2189 && (is_linden || (!is_muted && !is_busy)))
2185 && chatter != gAgent.getAvatarObject())
2186 { 2190 {
2187 gAgent.heardChat(chat); 2191 if (chat.mChatType != CHAT_TYPE_START
2188 if (ll_rand(2) == 0) 2192 && chat.mChatType != CHAT_TYPE_STOP)
2189 { 2193 {
2190 gAgent.setLookAt(LOOKAT_TARGET_AUTO_LISTEN, chatter, LLVector3::zero); 2194 gAgent.heardChat(chat.mFromID);
2191 } 2195 }
2192 } 2196 }
2193 2197
2194 is_owned_by_me = chatter->permYouOwner(); 2198 is_owned_by_me = chatter->permYouOwner();
@@ -2219,6 +2223,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2219 // Look for the start of typing so we can put "..." in the bubbles. 2223 // Look for the start of typing so we can put "..." in the bubbles.
2220 if (CHAT_TYPE_START == chat.mChatType) 2224 if (CHAT_TYPE_START == chat.mChatType)
2221 { 2225 {
2226 gLocalSpeakerMgr->setSpeakerTyping(from_id, TRUE);
2227
2222 // Might not have the avatar constructed yet, eg on login. 2228 // Might not have the avatar constructed yet, eg on login.
2223 if (chatter && chatter->isAvatar()) 2229 if (chatter && chatter->isAvatar())
2224 { 2230 {
@@ -2228,6 +2234,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2228 } 2234 }
2229 else if (CHAT_TYPE_STOP == chat.mChatType) 2235 else if (CHAT_TYPE_STOP == chat.mChatType)
2230 { 2236 {
2237 gLocalSpeakerMgr->setSpeakerTyping(from_id, FALSE);
2238
2231 // Might not have the avatar constructed yet, eg on login. 2239 // Might not have the avatar constructed yet, eg on login.
2232 if (chatter && chatter->isAvatar()) 2240 if (chatter && chatter->isAvatar())
2233 { 2241 {
@@ -2239,6 +2247,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
2239 // We have a real utterance now, so can stop showing "..." and proceed. 2247 // We have a real utterance now, so can stop showing "..." and proceed.
2240 if (chatter && chatter->isAvatar()) 2248 if (chatter && chatter->isAvatar())
2241 { 2249 {
2250 gLocalSpeakerMgr->setSpeakerTyping(from_id, FALSE);
2242 ((LLVOAvatar*)chatter)->stopTyping(); 2251 ((LLVOAvatar*)chatter)->stopTyping();
2243 2252
2244 if (!is_muted && !is_busy) 2253 if (!is_muted && !is_busy)
@@ -2367,7 +2376,7 @@ void process_teleport_start(LLMessageSystem *msg, void**)
2367 gTeleportDisplay = TRUE; 2376 gTeleportDisplay = TRUE;
2368 gAgent.setTeleportState( LLAgent::TELEPORT_START ); 2377 gAgent.setTeleportState( LLAgent::TELEPORT_START );
2369 make_ui_sound("UISndTeleportOut"); 2378 make_ui_sound("UISndTeleportOut");
2370 2379
2371 // Don't call LLFirstUse::useTeleport here because this could be 2380 // Don't call LLFirstUse::useTeleport here because this could be
2372 // due to being killed, which would send you home, not to a Telehub 2381 // due to being killed, which would send you home, not to a Telehub
2373 } 2382 }
@@ -2748,7 +2757,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
2748 { 2757 {
2749 avatarp->mFootPlane.clearVec(); 2758 avatarp->mFootPlane.clearVec();
2750 } 2759 }
2751 2760
2752 // reset always run status 2761 // reset always run status
2753 msg->newMessageFast(_PREHASH_SetAlwaysRun); 2762 msg->newMessageFast(_PREHASH_SetAlwaysRun);
2754 msg->nextBlockFast(_PREHASH_AgentData); 2763 msg->nextBlockFast(_PREHASH_AgentData);
@@ -3212,7 +3221,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **)
3212 if (!gParcelMgr->canHearSound(pos_global)) return; 3221 if (!gParcelMgr->canHearSound(pos_global)) return;
3213 3222
3214 // Don't play sounds triggered by someone you muted. 3223 // Don't play sounds triggered by someone you muted.
3215 if (gMuteListp->isMuted(owner_id)) return; 3224 if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return;
3216 3225
3217 // Don't play sounds from an object you muted 3226 // Don't play sounds from an object you muted
3218 if (gMuteListp->isMuted(object_id)) return; 3227 if (gMuteListp->isMuted(object_id)) return;
@@ -3224,7 +3233,8 @@ void process_sound_trigger(LLMessageSystem *msg, void **)
3224 return; 3233 return;
3225 } 3234 }
3226 3235
3227 gAudiop->triggerSound(sound_id, owner_id, gain, pos_global); 3236 F32 volume = gain * gSavedSettings.getF32("AudioLevelSFX");
3237 gAudiop->triggerSound(sound_id, owner_id, volume, pos_global);
3228} 3238}
3229 3239
3230void process_preload_sound(LLMessageSystem *msg, void **user_data) 3240void process_preload_sound(LLMessageSystem *msg, void **user_data)
@@ -3246,7 +3256,7 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
3246 if (!objectp) return; 3256 if (!objectp) return;
3247 3257
3248 if (gMuteListp->isMuted(object_id)) return; 3258 if (gMuteListp->isMuted(object_id)) return;
3249 if (gMuteListp->isMuted(owner_id)) return; 3259 if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return;
3250 3260
3251 LLAudioSource *sourcep = objectp->getAudioSource(owner_id); 3261 LLAudioSource *sourcep = objectp->getAudioSource(owner_id);
3252 if (!sourcep) return; 3262 if (!sourcep) return;
@@ -3284,7 +3294,7 @@ void process_attached_sound(LLMessageSystem *msg, void **user_data)
3284 3294
3285 if (gMuteListp->isMuted(object_id)) return; 3295 if (gMuteListp->isMuted(object_id)) return;
3286 3296
3287 if (gMuteListp->isMuted(owner_id)) return; 3297 if (gMuteListp->isMuted(owner_id, LLMute::flagObjectSounds)) return;
3288 3298
3289 objectp->setAttachedSound(sound_id, owner_id, gain, flags); 3299 objectp->setAttachedSound(sound_id, owner_id, gain, flags);
3290} 3300}