llmutelist.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_MUTELIST_H
00033 #define LL_MUTELIST_H
00034 
00035 #include "llstring.h"
00036 #include "lluuid.h"
00037 
00038 class LLViewerObject;
00039 class LLMessageSystem;
00040 class LLMuteListObserver;
00041 
00042 // An entry in the mute list.
00043 class LLMute
00044 {
00045 public:
00046         // Legacy mutes are BY_NAME and have null UUID.
00047         enum EType { BY_NAME = 0, AGENT = 1, OBJECT = 2, GROUP = 3, COUNT = 4 };
00048         
00049         // Bits in the mute flags.  For backwards compatibility (since any mute list entries that were created before the flags existed
00050         // will have a flags field of 0), some of the flags are "inverted".
00051         // Note that it's possible, through flags, to completely disable an entry in the mute list.  The code should detect this case
00052         // and remove the mute list entry instead.
00053         enum 
00054         {
00055                 flagTextChat            = 0x00000001,           // If set, don't mute user's text chat
00056                 flagVoiceChat           = 0x00000002,           // If set, don't mute user's voice chat
00057                 flagParticles           = 0x00000004,           // If set, don't mute user's particles
00058                 flagObjectSounds        = 0x00000008,           // If set, mute user's object sounds
00059                 
00060                 flagAll                         = 0x0000000F            // Mask of all currently defined flags
00061         };
00062         
00063         LLMute(const LLUUID& id, const LLString& name = LLString(), EType type = BY_NAME, U32 flags = 0) 
00064         : mID(id), mName(name), mType(type),mFlags(flags) { }
00065 
00066         // Returns name + suffix based on type
00067         // For example:  "James Tester (resident)"
00068         LLString getDisplayName() const;
00069         
00070         // Converts a UI name into just the agent or object name
00071         // For example: "James Tester (resident)" sets the name to "James Tester"
00072         // and the type to AGENT.
00073         void setFromDisplayName(const LLString& display_name);
00074         
00075 public:
00076         LLUUID          mID;    // agent or object id
00077         LLString        mName;  // agent or object name
00078         EType           mType;  // needed for UI display of existing mutes
00079         U32                     mFlags; // flags pertaining to this mute entry
00080 };
00081 
00082 class LLMuteList
00083 {
00084 public:
00085         LLMuteList();
00086         ~LLMuteList();
00087 
00088         void addObserver(LLMuteListObserver* observer);
00089         void removeObserver(LLMuteListObserver* observer);
00090 
00091         // Add either a normal or a BY_NAME mute, for any or all properties.
00092         BOOL add(const LLMute& mute, U32 flags = 0);
00093 
00094         // Remove both normal and legacy mutes, for any or all properties.
00095         BOOL remove(const LLMute& mute, U32 flags = 0);
00096         
00097         // Name is required to test against legacy text-only mutes.
00098         BOOL isMuted(const LLUUID& id, const LLString& name = LLString::null, U32 flags = 0) const;
00099         
00100         // Alternate (convenience) form for places we don't need to pass the name, but do need flags
00101         BOOL isMuted(const LLUUID& id, U32 flags) const { return isMuted(id, LLString::null, flags); };
00102         
00103         BOOL isLinden(const LLString& name) const;
00104         
00105         BOOL isLoaded() const { return mIsLoaded; }
00106 
00107         std::vector<LLMute> getMutes() const;
00108         
00109         // request the mute list
00110         void requestFromServer(const LLUUID& agent_id);
00111 
00112         // call this method on logout to save everything.
00113         void cache(const LLUUID& agent_id);
00114 
00115 private:
00116         BOOL loadFromFile(const LLString& filename);
00117         BOOL saveToFile(const LLString& filename);
00118 
00119         void setLoaded();
00120         void notifyObservers();
00121 
00122         void updateAdd(const LLMute& mute);
00123         void updateRemove(const LLMute& mute);
00124 
00125         // TODO: NULL out mute_id in database
00126         static void processMuteListUpdate(LLMessageSystem* msg, void**);
00127         static void processUseCachedMuteList(LLMessageSystem* msg, void**);
00128 
00129         static void onFileMuteList(void** user_data, S32 code, LLExtStat ext_status);
00130 
00131 private:
00132         struct compare_by_name
00133         {
00134                 bool operator()(const LLMute& a, const LLMute& b) const
00135                 {
00136                         return a.mName < b.mName;
00137                 }
00138         };
00139         struct compare_by_id
00140         {
00141                 bool operator()(const LLMute& a, const LLMute& b) const
00142                 {
00143                         return a.mID < b.mID;
00144                 }
00145         };
00146         typedef std::set<LLMute, compare_by_id> mute_set_t;
00147         mute_set_t mMutes;
00148         
00149         typedef std::set<LLString> string_set_t;
00150         string_set_t mLegacyMutes;
00151         
00152         typedef std::set<LLMuteListObserver*> observer_set_t;
00153         observer_set_t mObservers;
00154 
00155         BOOL mIsLoaded;
00156 
00157         friend class LLDispatchEmptyMuteList;
00158 };
00159 
00160 class LLMuteListObserver
00161 {
00162 public:
00163         virtual ~LLMuteListObserver() { }
00164         virtual void onChange() = 0;
00165 };
00166 
00167 extern LLMuteList *gMuteListp;
00168 
00169 #endif //LL_MUTELIST_H

Generated on Thu Jul 1 06:08:54 2010 for Second Life Viewer by  doxygen 1.4.7