aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmutelist.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llmutelist.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/newview/llmutelist.cpp')
-rw-r--r--linden/indra/newview/llmutelist.cpp124
1 files changed, 102 insertions, 22 deletions
diff --git a/linden/indra/newview/llmutelist.cpp b/linden/indra/newview/llmutelist.cpp
index bca9080..b5764c5 100644
--- a/linden/indra/newview/llmutelist.cpp
+++ b/linden/indra/newview/llmutelist.cpp
@@ -189,11 +189,11 @@ BOOL LLMuteList::isLinden(const LLString& name) const
189} 189}
190 190
191 191
192BOOL LLMuteList::add(const LLMute& mute) 192BOOL LLMuteList::add(const LLMute& mute, U32 flags)
193{ 193{
194 // Can't mute Lindens 194 // Can't mute text from Lindens
195 if ((mute.mType == LLMute::AGENT || mute.mType == LLMute::BY_NAME) 195 if ((mute.mType == LLMute::AGENT || mute.mType == LLMute::BY_NAME)
196 && isLinden(mute.mName)) 196 && isLinden(mute.mName) && (flags & LLMute::flagTextChat || flags == 0))
197 { 197 {
198 gViewerWindow->alertXml("MuteLinden"); 198 gViewerWindow->alertXml("MuteLinden");
199 return FALSE; 199 return FALSE;
@@ -238,25 +238,59 @@ BOOL LLMuteList::add(const LLMute& mute)
238 } 238 }
239 else 239 else
240 { 240 {
241 std::pair<mute_set_t::iterator, bool> result = mMutes.insert(mute); 241 // Need a local (non-const) copy to set up flags properly.
242 if (result.second) 242 LLMute localmute = mute;
243
244 // If an entry for the same entity is already in the list, remove it, saving flags as necessary.
245 mute_set_t::iterator it = mMutes.find(localmute);
246 if (it != mMutes.end())
243 { 247 {
244 llinfos << "Muting " << mute.mName << " id " << mute.mID << llendl; 248 // This mute is already in the list. Save the existing entry's flags if that's warranted.
245 updateAdd(mute); 249 localmute.mFlags = it->mFlags;
246 notifyObservers(); 250
247 //Kill all particle systems owned by muted task 251 mMutes.erase(it);
248 if(mute.mType == LLMute::AGENT || mute.mType == LLMute::OBJECT) 252 // Don't need to call notifyObservers() here, since it will happen after the entry has been re-added below.
249 { 253 }
250 gWorldPointer->mPartSim.cleanMutedParticles(mute.mID); 254 else
251 } 255 {
256 // There was no entry in the list previously. Fake things up by making it look like the previous entry had all properties unmuted.
257 localmute.mFlags = LLMute::flagAll;
258 }
252 259
253 return TRUE; 260 if(flags)
261 {
262 // The user passed some combination of flags. Make sure those flag bits are turned off (i.e. those properties will be muted).
263 localmute.mFlags &= (~flags);
254 } 264 }
255 else 265 else
256 { 266 {
257 return FALSE; 267 // The user passed 0. Make sure all flag bits are turned off (i.e. all properties will be muted).
268 localmute.mFlags = 0;
269 }
270
271 // (re)add the mute entry.
272 {
273 std::pair<mute_set_t::iterator, bool> result = mMutes.insert(localmute);
274 if (result.second)
275 {
276 llinfos << "Muting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
277 updateAdd(mute);
278 notifyObservers();
279 if(!(localmute.mFlags & LLMute::flagParticles))
280 {
281 //Kill all particle systems owned by muted task
282 if(localmute.mType == LLMute::AGENT || localmute.mType == LLMute::OBJECT)
283 {
284 gWorldPointer->mPartSim.cleanMutedParticles(localmute.mID);
285 }
286 }
287 return TRUE;
288 }
258 } 289 }
259 } 290 }
291
292 // If we were going to return success, we'd have done it by now.
293 return FALSE;
260} 294}
261 295
262void LLMuteList::updateAdd(const LLMute& mute) 296void LLMuteList::updateAdd(const LLMute& mute)
@@ -271,14 +305,14 @@ void LLMuteList::updateAdd(const LLMute& mute)
271 msg->addUUIDFast(_PREHASH_MuteID, mute.mID); 305 msg->addUUIDFast(_PREHASH_MuteID, mute.mID);
272 msg->addStringFast(_PREHASH_MuteName, mute.mName); 306 msg->addStringFast(_PREHASH_MuteName, mute.mName);
273 msg->addS32("MuteType", mute.mType); 307 msg->addS32("MuteType", mute.mType);
274 msg->addU32("MuteFlags", 0x0); // future 308 msg->addU32("MuteFlags", mute.mFlags);
275 gAgent.sendReliableMessage(); 309 gAgent.sendReliableMessage();
276 310
277 mIsLoaded = TRUE; 311 mIsLoaded = TRUE;
278} 312}
279 313
280 314
281BOOL LLMuteList::remove(const LLMute& mute) 315BOOL LLMuteList::remove(const LLMute& mute, U32 flags)
282{ 316{
283 BOOL found = FALSE; 317 BOOL found = FALSE;
284 318
@@ -286,8 +320,46 @@ BOOL LLMuteList::remove(const LLMute& mute)
286 mute_set_t::iterator it = mMutes.find(mute); 320 mute_set_t::iterator it = mMutes.find(mute);
287 if (it != mMutes.end()) 321 if (it != mMutes.end())
288 { 322 {
289 updateRemove(*it); 323 LLMute localmute = *it;
324 bool remove = true;
325 if(flags)
326 {
327 // If the user passed mute flags, we may only want to turn some flags on.
328 localmute.mFlags |= flags;
329
330 if(localmute.mFlags == LLMute::flagAll)
331 {
332 // Every currently available mute property has been masked out.
333 // Remove the mute entry entirely.
334 }
335 else
336 {
337 // Only some of the properties are masked out. Update the entry.
338 remove = false;
339 }
340 }
341 else
342 {
343 // The caller didn't pass any flags -- just remove the mute entry entirely.
344 }
345
346 // Always remove the entry from the set -- it will be re-added with new flags if necessary.
290 mMutes.erase(it); 347 mMutes.erase(it);
348
349 if(remove)
350 {
351 // The entry was actually removed. Notify the server.
352 updateRemove(localmute);
353 llinfos << "Unmuting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
354 }
355 else
356 {
357 // Flags were updated, the mute entry needs to be retransmitted to the server and re-added to the list.
358 mMutes.insert(localmute);
359 updateAdd(localmute);
360 llinfos << "Updating mute entry " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
361 }
362
291 // Must be after erase. 363 // Must be after erase.
292 notifyObservers(); 364 notifyObservers();
293 found = TRUE; 365 found = TRUE;
@@ -381,7 +453,7 @@ BOOL LLMuteList::loadFromFile(const LLString& filename)
381 buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer, 453 buffer, " %d %254s %254[^|]| %u\n", &type, id_buffer, name_buffer,
382 &flags); 454 &flags);
383 LLUUID id = LLUUID(id_buffer); 455 LLUUID id = LLUUID(id_buffer);
384 LLMute mute(id, name_buffer, (LLMute::EType)type); 456 LLMute mute(id, name_buffer, (LLMute::EType)type, flags);
385 if (mute.mID.isNull() 457 if (mute.mID.isNull()
386 || mute.mType == LLMute::BY_NAME) 458 || mute.mType == LLMute::BY_NAME)
387 { 459 {
@@ -430,19 +502,27 @@ BOOL LLMuteList::saveToFile(const LLString& filename)
430 { 502 {
431 it->mID.toString(id_string); 503 it->mID.toString(id_string);
432 const LLString& name = it->mName; 504 const LLString& name = it->mName;
433 fprintf(fp, "%d %s %s|\n", (S32)it->mType, id_string, name.c_str()); 505 fprintf(fp, "%d %s %s|%u\n", (S32)it->mType, id_string, name.c_str(), it->mFlags);
434 } 506 }
435 fclose(fp); 507 fclose(fp);
436 return TRUE; 508 return TRUE;
437} 509}
438 510
439 511
440BOOL LLMuteList::isMuted(const LLUUID& id, const LLString& name) const 512BOOL LLMuteList::isMuted(const LLUUID& id, const LLString& name, U32 flags) const
441{ 513{
442 // don't need name or type for lookup 514 // don't need name or type for lookup
443 LLMute mute(id); 515 LLMute mute(id);
444 mute_set_t::const_iterator mute_it = mMutes.find(mute); 516 mute_set_t::const_iterator mute_it = mMutes.find(mute);
445 if (mute_it != mMutes.end()) return TRUE; 517 if (mute_it != mMutes.end())
518 {
519 // If any of the flags the caller passed are set, this item isn't considered muted for this caller.
520 if(flags & mute_it->mFlags)
521 {
522 return FALSE;
523 }
524 return TRUE;
525 }
446 526
447 // empty names can't be legacy-muted 527 // empty names can't be legacy-muted
448 if (name.empty()) return FALSE; 528 if (name.empty()) return FALSE;