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 00ef9c3..ef1c42f 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 |
@@ -72,6 +72,24 @@ | |||
72 | #include "llviewerobject.h" | 72 | #include "llviewerobject.h" |
73 | #include "llviewerobjectlist.h" | 73 | #include "llviewerobjectlist.h" |
74 | 74 | ||
75 | namespace | ||
76 | { | ||
77 | // This method is used to return an object to mute given an object id. | ||
78 | // Its used by the LLMute constructor and LLMuteList::isMuted. | ||
79 | LLViewerObject* get_object_to_mute_from_id(LLUUID object_id) | ||
80 | { | ||
81 | LLViewerObject *objectp = gObjectList.findObject(object_id); | ||
82 | if ((objectp) && (!objectp->isAvatar())) | ||
83 | { | ||
84 | LLViewerObject *parentp = (LLViewerObject *)objectp->getParent(); | ||
85 | if (parentp && parentp->getID() != gAgent.getID()) | ||
86 | { | ||
87 | objectp = parentp; | ||
88 | } | ||
89 | } | ||
90 | return objectp; | ||
91 | } | ||
92 | } | ||
75 | 93 | ||
76 | // "emptymutelist" | 94 | // "emptymutelist" |
77 | class LLDispatchEmptyMuteList : public LLDispatchHandler | 95 | class LLDispatchEmptyMuteList : public LLDispatchHandler |
@@ -98,6 +116,32 @@ const char AGENT_SUFFIX[] = " (resident)"; | |||
98 | const char OBJECT_SUFFIX[] = " (object)"; | 116 | const char OBJECT_SUFFIX[] = " (object)"; |
99 | const char GROUP_SUFFIX[] = " (group)"; | 117 | const char GROUP_SUFFIX[] = " (group)"; |
100 | 118 | ||
119 | |||
120 | LLMute::LLMute(const LLUUID& id, const std::string& name, EType type, U32 flags) | ||
121 | : mID(id), | ||
122 | mName(name), | ||
123 | mType(type), | ||
124 | mFlags(flags) | ||
125 | { | ||
126 | // muting is done by root objects only - try to find this objects root | ||
127 | LLViewerObject* mute_object = get_object_to_mute_from_id(id); | ||
128 | if(mute_object && mute_object->getID() != id) | ||
129 | { | ||
130 | mID = mute_object->getID(); | ||
131 | LLNameValue* firstname = mute_object->getNVPair("FirstName"); | ||
132 | LLNameValue* lastname = mute_object->getNVPair("LastName"); | ||
133 | if (firstname && lastname) | ||
134 | { | ||
135 | mName.assign( firstname->getString() ); | ||
136 | mName.append(" "); | ||
137 | mName.append( lastname->getString() ); | ||
138 | } | ||
139 | mType = mute_object->isAvatar() ? AGENT : OBJECT; | ||
140 | } | ||
141 | |||
142 | } | ||
143 | |||
144 | |||
101 | std::string LLMute::getDisplayName() const | 145 | std::string LLMute::getDisplayName() const |
102 | { | 146 | { |
103 | std::string name_with_suffix = mName; | 147 | std::string name_with_suffix = mName; |
@@ -217,17 +261,24 @@ void LLMuteList::loadUserVolumes() | |||
217 | //----------------------------------------------------------------------------- | 261 | //----------------------------------------------------------------------------- |
218 | LLMuteList::~LLMuteList() | 262 | LLMuteList::~LLMuteList() |
219 | { | 263 | { |
220 | std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); | 264 | // If we quit from the login screen we will not have an SL account |
221 | LLSD settings_llsd; | 265 | // name. Don't try to save, otherwise we'll dump a file in |
222 | 266 | // C:\Program Files\SecondLife\ JC | |
223 | for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) | 267 | std::string user_dir = gDirUtilp->getLindenUserDir(); |
268 | if (!user_dir.empty()) | ||
224 | { | 269 | { |
225 | settings_llsd[iter->first.asString()] = iter->second; | 270 | std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "volume_settings.xml"); |
226 | } | 271 | LLSD settings_llsd; |
227 | 272 | ||
228 | llofstream file; | 273 | for(user_volume_map_t::iterator iter = mUserVolumeSettings.begin(); iter != mUserVolumeSettings.end(); ++iter) |
229 | file.open(filename); | 274 | { |
230 | LLSDSerialize::toPrettyXML(settings_llsd, file); | 275 | settings_llsd[iter->first.asString()] = iter->second; |
276 | } | ||
277 | |||
278 | llofstream file; | ||
279 | file.open(filename); | ||
280 | LLSDSerialize::toPrettyXML(settings_llsd, file); | ||
281 | } | ||
231 | } | 282 | } |
232 | 283 | ||
233 | BOOL LLMuteList::isLinden(const std::string& name) const | 284 | BOOL LLMuteList::isLinden(const std::string& name) const |
@@ -673,19 +724,10 @@ BOOL LLMuteList::saveToFile(const std::string& filename) | |||
673 | 724 | ||
674 | BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const | 725 | BOOL LLMuteList::isMuted(const LLUUID& id, const std::string& name, U32 flags) const |
675 | { | 726 | { |
676 | LLUUID id_to_check = id; | ||
677 | |||
678 | // for objects, check for muting on their parent prim | 727 | // for objects, check for muting on their parent prim |
679 | LLViewerObject *objectp = gObjectList.findObject(id); | 728 | LLViewerObject* mute_object = get_object_to_mute_from_id(id); |
680 | if ((objectp) && (!objectp->isAvatar())) | 729 | LLUUID id_to_check = (mute_object) ? mute_object->getID() : id; |
681 | { | 730 | |
682 | LLViewerObject *parentp = (LLViewerObject *)objectp->getParent(); | ||
683 | if (parentp) | ||
684 | { | ||
685 | id_to_check = parentp->getID(); | ||
686 | } | ||
687 | } | ||
688 | |||
689 | // don't need name or type for lookup | 731 | // don't need name or type for lookup |
690 | LLMute mute(id_to_check); | 732 | LLMute mute(id_to_check); |
691 | mute_set_t::const_iterator mute_it = mMutes.find(mute); | 733 | mute_set_t::const_iterator mute_it = mMutes.find(mute); |