00001
00032 #ifndef LL_LLFLOATERACTIVESPEAKERS_H
00033 #define LL_LLFLOATERACTIVESPEAKERS_H
00034
00035 #include "llfloater.h"
00036 #include "llmemory.h"
00037 #include "llvoiceclient.h"
00038 #include "llframetimer.h"
00039 #include "llevent.h"
00040 #include <list>
00041
00042 class LLScrollListCtrl;
00043 class LLButton;
00044 class LLPanelActiveSpeakers;
00045 class LLSpeakerMgr;
00046 class LLVoiceChannel;
00047
00048
00049
00050 class LLSpeaker : public LLRefCount, public LLObservable, public LLHandleProvider<LLSpeaker>
00051 {
00052 public:
00053 typedef enum e_speaker_type
00054 {
00055 SPEAKER_AGENT,
00056 SPEAKER_OBJECT
00057 } ESpeakerType;
00058
00059 typedef enum e_speaker_status
00060 {
00061 STATUS_SPEAKING,
00062 STATUS_HAS_SPOKEN,
00063 STATUS_VOICE_ACTIVE,
00064 STATUS_TEXT_ONLY,
00065 STATUS_NOT_IN_CHANNEL,
00066 STATUS_MUTED
00067 } ESpeakerStatus;
00068
00069
00070 LLSpeaker(const LLUUID& id, const LLString& name = LLString::null, const ESpeakerType type = SPEAKER_AGENT);
00071 ~LLSpeaker() {};
00072 void lookupName();
00073
00074 static void onAvatarNameLookup(const LLUUID& id, const char* first, const char* last, BOOL is_group, void* user_data);
00075
00076 ESpeakerStatus mStatus;
00077 F32 mLastSpokeTime;
00078 F32 mSpeechVolume;
00079 LLString mDisplayName;
00080 LLFrameTimer mActivityTimer;
00081 BOOL mHasSpoken;
00082 LLColor4 mDotColor;
00083 LLUUID mID;
00084 BOOL mTyping;
00085 S32 mSortIndex;
00086 ESpeakerType mType;
00087 BOOL mIsModerator;
00088 BOOL mModeratorMutedVoice;
00089 BOOL mModeratorMutedText;
00090 };
00091
00092 class LLSpeakerTextModerationEvent : public LLEvent
00093 {
00094 public:
00095 LLSpeakerTextModerationEvent(LLSpeaker* source);
00096 LLSD getValue();
00097 };
00098
00099 class LLSpeakerVoiceModerationEvent : public LLEvent
00100 {
00101 public:
00102 LLSpeakerVoiceModerationEvent(LLSpeaker* source);
00103 LLSD getValue();
00104 };
00105
00106 class LLSpeakerListChangeEvent : public LLEvent
00107 {
00108 public:
00109 LLSpeakerListChangeEvent(LLSpeakerMgr* source, const LLUUID& speaker_id);
00110 LLSD getValue();
00111
00112 private:
00113 const LLUUID& mSpeakerID;
00114 };
00115
00116 class LLSpeakerMgr : public LLObservable
00117 {
00118 public:
00119 LLSpeakerMgr(LLVoiceChannel* channelp);
00120 virtual ~LLSpeakerMgr();
00121
00122 const LLPointer<LLSpeaker> findSpeaker(const LLUUID& avatar_id);
00123 void update();
00124 void setSpeakerTyping(const LLUUID& speaker_id, BOOL typing);
00125 void speakerChatted(const LLUUID& speaker_id);
00126 LLPointer<LLSpeaker> setSpeaker(const LLUUID& id,
00127 const LLString& name = LLString::null,
00128 LLSpeaker::ESpeakerStatus status = LLSpeaker::STATUS_TEXT_ONLY,
00129 LLSpeaker::ESpeakerType = LLSpeaker::SPEAKER_AGENT);
00130
00131 BOOL isVoiceActive();
00132
00133 typedef std::vector<LLPointer<LLSpeaker> > speaker_list_t;
00134 void getSpeakerList(speaker_list_t* speaker_list, BOOL include_text);
00135 const LLUUID getSessionID();
00136
00137 protected:
00138 virtual void updateSpeakerList();
00139
00140 typedef std::map<LLUUID, LLPointer<LLSpeaker> > speaker_map_t;
00141 speaker_map_t mSpeakers;
00142
00143 speaker_list_t mSpeakersSorted;
00144 LLFrameTimer mSpeechTimer;
00145 LLVoiceChannel* mVoiceChannel;
00146 };
00147
00148 class LLIMSpeakerMgr : public LLSpeakerMgr
00149 {
00150 public:
00151 LLIMSpeakerMgr(LLVoiceChannel* channel);
00152
00153 void updateSpeakers(const LLSD& update);
00154 void setSpeakers(const LLSD& speakers);
00155 protected:
00156 virtual void updateSpeakerList();
00157 };
00158
00159 class LLActiveSpeakerMgr : public LLSpeakerMgr, public LLSingleton<LLActiveSpeakerMgr>
00160 {
00161 public:
00162 LLActiveSpeakerMgr();
00163 protected:
00164 virtual void updateSpeakerList();
00165 };
00166
00167 class LLLocalSpeakerMgr : public LLSpeakerMgr, public LLSingleton<LLLocalSpeakerMgr>
00168 {
00169 public:
00170 LLLocalSpeakerMgr();
00171 ~LLLocalSpeakerMgr ();
00172 protected:
00173 virtual void updateSpeakerList();
00174 };
00175
00176
00177 class LLFloaterActiveSpeakers :
00178 public LLFloaterSingleton<LLFloaterActiveSpeakers>,
00179 public LLFloater,
00180 public LLVoiceClientParticipantObserver
00181 {
00182
00183
00184 friend class LLUISingleton<LLFloaterActiveSpeakers, VisibilityPolicy<LLFloater> >;
00185 public:
00186 virtual ~LLFloaterActiveSpeakers();
00187
00188 BOOL postBuild();
00189 void onOpen();
00190 void onClose(bool app_quitting);
00191 void draw();
00192
00193 void onChange();
00194
00195 static void* createSpeakersPanel(void* data);
00196
00197 protected:
00198 LLFloaterActiveSpeakers(const LLSD& seed);
00199
00200 LLPanelActiveSpeakers* mPanel;
00201 };
00202
00203 class LLPanelActiveSpeakers : public LLPanel
00204 {
00205 public:
00206 LLPanelActiveSpeakers(LLSpeakerMgr* data_source, BOOL show_text_chatters);
00207
00208 BOOL postBuild();
00209
00210 void handleSpeakerSelect();
00211 void refreshSpeakers();
00212
00213 void setSpeaker(const LLUUID& id,
00214 const LLString& name = LLString::null,
00215 LLSpeaker::ESpeakerStatus status = LLSpeaker::STATUS_TEXT_ONLY,
00216 LLSpeaker::ESpeakerType = LLSpeaker::SPEAKER_AGENT);
00217
00218 void setVoiceModerationCtrlMode(const BOOL& moderated_voice);
00219
00220 static void onClickMuteVoice(void* user_data);
00221 static void onClickMuteVoiceCommit(LLUICtrl* ctrl, void* user_data);
00222 static void onClickMuteTextCommit(LLUICtrl* ctrl, void* user_data);
00223 static void onVolumeChange(LLUICtrl* source, void* user_data);
00224 static void onClickProfile(void* user_data);
00225 static void onDoubleClickSpeaker(void* user_data);
00226 static void onSelectSpeaker(LLUICtrl* source, void* user_data);
00227 static void onSortChanged(void* user_data);
00228 static void onModeratorMuteVoice(LLUICtrl* ctrl, void* user_data);
00229 static void onModeratorMuteText(LLUICtrl* ctrl, void* user_data);
00230 static void onChangeModerationMode(LLUICtrl* ctrl, void* user_data);
00231
00232 protected:
00233 class SpeakerMuteListener : public LLSimpleListener
00234 {
00235 public:
00236 SpeakerMuteListener(LLPanelActiveSpeakers* panel) : mPanel(panel) {}
00237
00238 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
00239
00240 LLPanelActiveSpeakers* mPanel;
00241 };
00242
00243 friend class SpeakerAddListener;
00244 class SpeakerAddListener : public LLSimpleListener
00245 {
00246 public:
00247 SpeakerAddListener(LLPanelActiveSpeakers* panel) : mPanel(panel) {}
00248
00249 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
00250
00251 LLPanelActiveSpeakers* mPanel;
00252 };
00253
00254 friend class SpeakerRemoveListener;
00255 class SpeakerRemoveListener : public LLSimpleListener
00256 {
00257 public:
00258 SpeakerRemoveListener(LLPanelActiveSpeakers* panel) : mPanel(panel) {}
00259
00260 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
00261
00262 LLPanelActiveSpeakers* mPanel;
00263 };
00264
00265
00266 friend class SpeakerClearListener;
00267 class SpeakerClearListener : public LLSimpleListener
00268 {
00269 public:
00270 SpeakerClearListener(LLPanelActiveSpeakers* panel) : mPanel(panel) {}
00271
00272 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
00273
00274 LLPanelActiveSpeakers* mPanel;
00275 };
00276
00277 void addSpeaker(const LLUUID& id);
00278 void removeSpeaker(const LLUUID& id);
00279
00280
00281 LLScrollListCtrl* mSpeakerList;
00282 LLUICtrl* mMuteVoiceCtrl;
00283 LLUICtrl* mMuteTextCtrl;
00284 LLTextBox* mNameText;
00285 LLButton* mProfileBtn;
00286 BOOL mShowTextChatters;
00287 LLSpeakerMgr* mSpeakerMgr;
00288 LLFrameTimer mIconAnimationTimer;
00289 LLPointer<SpeakerMuteListener> mSpeakerMuteListener;
00290 LLPointer<SpeakerAddListener> mSpeakerAddListener;
00291 LLPointer<SpeakerRemoveListener> mSpeakerRemoveListener;
00292 LLPointer<SpeakerClearListener> mSpeakerClearListener;
00293 };
00294
00295
00296 #endif // LL_LLFLOATERACTIVESPEAKERS_H