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 : public LLSingleton<LLMuteList>
00083 {
00084 public:
00085         // reasons for auto-unmuting a resident
00086         enum EAutoReason 
00087         { 
00088                 AR_IM = 0,                      // agent IMed a muted resident
00089                 AR_MONEY = 1,                   // agent paid L$ to a muted resident
00090                 AR_INVENTORY = 2,       // agent offered inventory to a muted resident
00091                 AR_COUNT                        // enum count
00092         };
00093 
00094         LLMuteList();
00095         ~LLMuteList();
00096 
00097         // Implemented locally so that we can perform some delayed initialization. 
00098         // Callers should be careful to call this one and not LLSingleton<LLMuteList>::getInstance()
00099         // which would circumvent that mechanism. -MG
00100         static LLMuteList* getInstance();
00101 
00102         void addObserver(LLMuteListObserver* observer);
00103         void removeObserver(LLMuteListObserver* observer);
00104 
00105         // Add either a normal or a BY_NAME mute, for any or all properties.
00106         BOOL add(const LLMute& mute, U32 flags = 0);
00107 
00108         // Remove both normal and legacy mutes, for any or all properties.
00109         BOOL remove(const LLMute& mute, U32 flags = 0);
00110         BOOL autoRemove(const LLUUID& agent_id, const EAutoReason reason, const LLString& first_name = "", const LLString& last_name = "");
00111         
00112         // Name is required to test against legacy text-only mutes.
00113         BOOL isMuted(const LLUUID& id, const LLString& name = LLString::null, U32 flags = 0) const;
00114         
00115         // Alternate (convenience) form for places we don't need to pass the name, but do need flags
00116         BOOL isMuted(const LLUUID& id, U32 flags) const { return isMuted(id, LLString::null, flags); };
00117         
00118         BOOL isLinden(const LLString& name) const;
00119         
00120         BOOL isLoaded() const { return mIsLoaded; }
00121 
00122         std::vector<LLMute> getMutes() const;
00123         
00124         // request the mute list
00125         void requestFromServer(const LLUUID& agent_id);
00126 
00127         // call this method on logout to save everything.
00128         void cache(const LLUUID& agent_id);
00129 
00130         void setSavedResidentVolume(const LLUUID& id, F32 volume);
00131         F32 getSavedResidentVolume(const LLUUID& id);
00132 
00133 private:
00134         BOOL loadFromFile(const LLString& filename);
00135         BOOL saveToFile(const LLString& filename);
00136 
00137         void setLoaded();
00138         void notifyObservers();
00139 
00140         void updateAdd(const LLMute& mute);
00141         void updateRemove(const LLMute& mute);
00142 
00143         // TODO: NULL out mute_id in database
00144         static void processMuteListUpdate(LLMessageSystem* msg, void**);
00145         static void processUseCachedMuteList(LLMessageSystem* msg, void**);
00146 
00147         static void onFileMuteList(void** user_data, S32 code, LLExtStat ext_status);
00148 
00149 private:
00150         struct compare_by_name
00151         {
00152                 bool operator()(const LLMute& a, const LLMute& b) const
00153                 {
00154                         return a.mName < b.mName;
00155                 }
00156         };
00157         struct compare_by_id
00158         {
00159                 bool operator()(const LLMute& a, const LLMute& b) const
00160                 {
00161                         return a.mID < b.mID;
00162                 }
00163         };
00164         typedef std::set<LLMute, compare_by_id> mute_set_t;
00165         mute_set_t mMutes;
00166         
00167         typedef std::set<LLString> string_set_t;
00168         string_set_t mLegacyMutes;
00169         
00170         typedef std::set<LLMuteListObserver*> observer_set_t;
00171         observer_set_t mObservers;
00172 
00173         BOOL mIsLoaded;
00174 
00175         friend class LLDispatchEmptyMuteList;
00176 
00177         typedef std::map<LLUUID, F32> user_volume_map_t; 
00178         static user_volume_map_t sUserVolumeSettings;
00179 };
00180 
00181 class LLMuteListObserver
00182 {
00183 public:
00184         virtual ~LLMuteListObserver() { }
00185         virtual void onChange() = 0;
00186 };
00187 
00188 
00189 #endif //LL_MUTELIST_H

Generated on Fri May 16 08:33:48 2008 for SecondLife by  doxygen 1.5.5