aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmutelist.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llmutelist.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llmutelist.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/linden/indra/newview/llmutelist.h b/linden/indra/newview/llmutelist.h
new file mode 100644
index 0000000..afd57ad
--- /dev/null
+++ b/linden/indra/newview/llmutelist.h
@@ -0,0 +1,147 @@
1/**
2 * @file llmutelist.h
3 * @brief Management of list of muted players
4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_MUTELIST_H
29#define LL_MUTELIST_H
30
31#include "llstring.h"
32#include "lluuid.h"
33
34class LLViewerObject;
35class LLMessageSystem;
36class LLMuteListObserver;
37
38// An entry in the mute list.
39class LLMute
40{
41public:
42 // Legacy mutes are BY_NAME and have null UUID.
43 enum EType { BY_NAME = 0, AGENT = 1, OBJECT = 2, GROUP = 3, COUNT = 4 };
44
45 LLMute(const LLUUID& id, const LLString& name = "", EType type = BY_NAME)
46 : mID(id), mName(name), mType(type) { }
47
48 // Returns name + suffix based on type
49 // For example: "James Tester (resident)"
50 LLString getDisplayName() const;
51
52 // Converts a UI name into just the agent or object name
53 // For example: "James Tester (resident)" sets the name to "James Tester"
54 // and the type to AGENT.
55 void setFromDisplayName(const LLString& display_name);
56
57public:
58 LLUUID mID; // agent or object id
59 LLString mName; // agent or object name
60 EType mType; // needed for UI display of existing mutes
61};
62
63class LLMuteList
64{
65public:
66 LLMuteList();
67 ~LLMuteList();
68
69 void addObserver(LLMuteListObserver* observer);
70 void removeObserver(LLMuteListObserver* observer);
71
72 // Add either a normal or a BY_NAME mute.
73 BOOL add(const LLMute& mute);
74
75 // Remove both normal and legacy mutes.
76 BOOL remove(const LLMute& mute);
77
78 // Name is required to test against legacy text-only mutes.
79 BOOL isMuted(const LLUUID& id, const LLString& name = LLString::null) const;
80
81 BOOL isLinden(const LLString& name) const;
82
83 BOOL isLoaded() const { return mIsLoaded; }
84
85 std::vector<LLMute> getMutes() const;
86
87 // request the mute list
88 void requestFromServer(const LLUUID& agent_id);
89
90 // call this method on logout to save everything.
91 void cache(const LLUUID& agent_id);
92
93private:
94 BOOL loadFromFile(const LLString& filename);
95 BOOL saveToFile(const LLString& filename);
96
97 void setLoaded();
98 void notifyObservers();
99
100 void updateAdd(const LLMute& mute);
101 void updateRemove(const LLMute& mute);
102
103 // TODO: NULL out mute_id in database
104 static void processMuteListUpdate(LLMessageSystem* msg, void**);
105 static void processUseCachedMuteList(LLMessageSystem* msg, void**);
106
107 static void onFileMuteList(void** user_data, S32 code);
108
109private:
110 struct compare_by_name
111 {
112 bool operator()(const LLMute& a, const LLMute& b) const
113 {
114 return a.mName < b.mName;
115 }
116 };
117 struct compare_by_id
118 {
119 bool operator()(const LLMute& a, const LLMute& b) const
120 {
121 return a.mID < b.mID;
122 }
123 };
124 typedef std::set<LLMute, compare_by_id> mute_set_t;
125 mute_set_t mMutes;
126
127 typedef std::set<LLString> string_set_t;
128 string_set_t mLegacyMutes;
129
130 typedef std::set<LLMuteListObserver*> observer_set_t;
131 observer_set_t mObservers;
132
133 BOOL mIsLoaded;
134
135 friend class LLDispatchEmptyMuteList;
136};
137
138class LLMuteListObserver
139{
140public:
141 virtual ~LLMuteListObserver() { }
142 virtual void onChange() = 0;
143};
144
145extern LLMuteList *gMuteListp;
146
147#endif //LL_MUTELIST_H