diff options
Diffstat (limited to 'linden/indra/newview/llmutelist.cpp')
-rw-r--r-- | linden/indra/newview/llmutelist.cpp | 86 |
1 files changed, 64 insertions, 22 deletions
diff --git a/linden/indra/newview/llmutelist.cpp b/linden/indra/newview/llmutelist.cpp index 0cdfe83..a9bf4b3 100644 --- a/linden/indra/newview/llmutelist.cpp +++ b/linden/indra/newview/llmutelist.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2003&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2003-2008, Linden Research, Inc. | 8 | * Copyright (c) 2003-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -71,6 +71,24 @@ | |||
71 | #include "llviewerobject.h" | 71 | #include "llviewerobject.h" |
72 | #include "llviewerobjectlist.h" | 72 | #include "llviewerobjectlist.h" |
73 | 73 | ||
74 | namespace | ||
75 | { | ||
76 | // This method is used to return an object to mute given an object id. | ||
77 | // Its used by the LLMute constructor and LLMuteList::isMuted. | ||
78 | LLViewerObject* get_object_to_mute_from_id(LLUUID object_id) | ||
79 | { | ||
80 | LLViewerObject *objectp = gObjectList.findObject(object_id); | ||
81 | if ((objectp) && (!objectp->isAvatar())) | ||
82 | { | ||
83 | LLViewerObject *parentp = (LLViewerObject *)objectp->getParent(); | ||
84 | if (parentp && parentp->getID() != gAgent.getID()) | ||
85 | { | ||
86 | objectp = parentp; | ||
87 | } | ||
88 | } | ||
89 | return objectp; | ||
90 | } | ||
91 | } | ||
74 | 92 | ||
75 | // "emptymutelist" | 93 | // "emptymutelist" |
76 | class LLDispatchEmptyMuteList : public LLDispatchHandler | 94 | class LLDispatchEmptyMuteList : public LLDispatchHandler |
@@ -97,6 +115,32 @@ const char AGENT_SUFFIX[] = " (resident)"; | |||
97 | const char OBJECT_SUFFIX[] = " (object)"; | 115 | const char OBJECT_SUFFIX[] = " (object)"; |
98 | const char GROUP_SUFFIX[] = " (group)"; | 116 | const char GROUP_SUFFIX[] = " (group)"; |
99 | 117 | ||
118 | |||
119 | LLMute::LLMute(const LLUUID& id, const std::string& name, EType type, U32 flags) | ||
120 | : mID(id), | ||
121 | mName(name), | ||
122 | mType(type), | ||
123 | mFlags(flags) | ||
124 | { | ||
125 | // muting is done by root objects only - try to find this objects root | ||
126 | LLViewerObject* mute_object = get_object_to_mute_from_id(id); | ||
127 | if(mute_object && mute_object->getID() != id) | ||
128 | { | ||
129 | mID = mute_object->getID(); | ||
130 | LLNameValue* firstname = mute_object->getNVPair("FirstName"); | ||
131 | LLNameValue* lastname = mute_object->getNVPair("LastName"); | ||
132 | if (firstname && lastname) | ||
133 | { | ||
134 | mName.assign( firstname->getString() ); | ||
135 | mName.append(" "); | ||
136 | mName.append( lastname->getString() ); | ||
137 | } | ||
138 | mType = mute_object->isAvatar() ? AGENT : OBJECT; | ||
139 | } | ||
140 | |||
141 | } | ||
142 | |||
143 | |||
100 | std::string LLMute::getDisplayName() const | 144 | std::string LLMute::getDisplayName() const |
101 | { | 145 | { |
102 | std::string name_with_suffix = mName; | 146 | std::string name_with_suffix = mName; |
@@ -216,17 +260,24 @@ void LLMuteList::loadUserVolumes() | |||
216 | //----------------------------------------------------------------------------- | 260 | //----------------------------------------------------------------------------- |
217 | LLMuteList::~LLMuteList() | 261 | LLMuteList::~LLMuteList() |
218 | { | 262 | { |
219 | std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); | 263 | // If we quit from the login screen we will not have an SL account |
220 | LLSD settings_llsd; | 264 | // name. Don't try to save, otherwise we'll dump a file in |
221 | 265 | // C:\Program Files\SecondLife\ JC | |
222 | for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) | 266 | std::string user_dir = gDirUtilp->getLindenUserDir(); |
267 | if (!user_dir.empty()) | ||
223 | { | 268 | { |
224 | settings_llsd[iter->first.asString()] = iter->second; | 269 | std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); |
225 | } | 270 | LLSD settings_llsd; |
226 | 271 | ||
227 | llofstream file; | 272 | for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) |
228 | file.open(filename); | 273 | { |
229 | LLSDSerialize::toPrettyXML(settings_llsd, file); | 274 | settings_llsd[iter->first.asString()] = iter->second; |
275 | } | ||
276 | |||
277 | llofstream file; | ||
278 | file.open(filename); | ||
279 | LLSDSerialize::toPrettyXML(settings_llsd, file); | ||
280 | } | ||
230 | } | 281 | } |
231 | 282 | ||
232 | BOOL LLMuteList::isLinden(const std::string& name) const | 283 | BOOL LLMuteList::isLinden(const std::string& name) const |
@@ -635,19 +686,10 @@ BOOL LLMuteList::saveToFile(const std::string& filename) | |||
635 | 686 | ||
636 | BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const | 687 | BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const |
637 | { | 688 | { |
638 | LLUUID id_to_check = id; | ||
639 | |||
640 | // for objects, check for muting on their parent prim | 689 | // for objects, check for muting on their parent prim |
641 | LLViewerObject *objectp = gObjectList.findObject(id); | 690 | LLViewerObject* mute_object = get_object_to_mute_from_id(id); |
642 | if ((objectp) && (!objectp->isAvatar())) | 691 | LLUUID id_to_check = (mute_object) ? mute_object->getID() : id; |
643 | { | 692 | |
644 | LLViewerObject *parentp = (LLViewerObject *)objectp->getParent(); | ||
645 | if (parentp) | ||
646 | { | ||
647 | id_to_check = parentp->getID(); | ||
648 | } | ||
649 | } | ||
650 | |||
651 | // don't need name or type for lookup | 693 | // don't need name or type for lookup |
652 | LLMute mute(id_to_check); | 694 | LLMute mute(id_to_check); |
653 | mute_set_t::const_iterator mute_it = mMutes.find(mute); | 695 | mute_set_t::const_iterator mute_it = mMutes.find(mute); |