/indra/newview/llparticipantlist.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 288 lines · 138 code · 41 blank · 109 comment · 0 complexity · 830091906810fe577f992263bd7ca9c9 MD5 · raw file

  1. /**
  2. * @file llparticipantlist.h
  3. * @brief LLParticipantList intended to update view(LLAvatarList) according to incoming messages
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_PARTICIPANTLIST_H
  27. #define LL_PARTICIPANTLIST_H
  28. #include "llviewerprecompiledheaders.h"
  29. #include "llevent.h"
  30. #include "llavatarlist.h" // for LLAvatarItemRecentSpeakerComparator
  31. #include "lllistcontextmenu.h"
  32. class LLSpeakerMgr;
  33. class LLAvatarList;
  34. class LLUICtrl;
  35. class LLAvalineUpdater;
  36. class LLParticipantList
  37. {
  38. LOG_CLASS(LLParticipantList);
  39. public:
  40. typedef boost::function<bool (const LLUUID& speaker_id)> validate_speaker_callback_t;
  41. LLParticipantList(LLSpeakerMgr* data_source,
  42. LLAvatarList* avatar_list,
  43. bool use_context_menu = true,
  44. bool exclude_agent = true,
  45. bool can_toggle_icons = true);
  46. ~LLParticipantList();
  47. void setSpeakingIndicatorsVisible(BOOL visible);
  48. enum EParticipantSortOrder
  49. {
  50. E_SORT_BY_NAME = 0,
  51. E_SORT_BY_RECENT_SPEAKERS = 1,
  52. };
  53. /**
  54. * Adds specified avatar ID to the existing list if it is not Agent's ID
  55. *
  56. * @param[in] avatar_id - Avatar UUID to be added into the list
  57. */
  58. void addAvatarIDExceptAgent(const LLUUID& avatar_id);
  59. /**
  60. * Set and sort Avatarlist by given order
  61. */
  62. void setSortOrder(EParticipantSortOrder order = E_SORT_BY_NAME);
  63. const EParticipantSortOrder getSortOrder() const;
  64. /**
  65. * Refreshes the participant list if it's in sort by recent speaker order.
  66. */
  67. void updateRecentSpeakersOrder();
  68. /**
  69. * Set a callback to be called before adding a speaker. Invalid speakers will not be added.
  70. *
  71. * If the callback is unset all speakers are considered as valid.
  72. *
  73. * @see onAddItemEvent()
  74. */
  75. void setValidateSpeakerCallback(validate_speaker_callback_t cb);
  76. protected:
  77. /**
  78. * LLSpeakerMgr event handlers
  79. */
  80. bool onAddItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  81. bool onRemoveItemEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  82. bool onClearListEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  83. bool onModeratorUpdateEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  84. bool onSpeakerMuteEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  85. /**
  86. * Sorts the Avatarlist by stored order
  87. */
  88. void sort();
  89. /**
  90. * List of listeners implementing LLOldEvents::LLSimpleListener.
  91. * There is no way to handle all the events in one listener as LLSpeakerMgr registers
  92. * listeners in such a way that one listener can handle only one type of event
  93. **/
  94. class BaseSpeakerListener : public LLOldEvents::LLSimpleListener
  95. {
  96. public:
  97. BaseSpeakerListener(LLParticipantList& parent) : mParent(parent) {}
  98. protected:
  99. LLParticipantList& mParent;
  100. };
  101. class SpeakerAddListener : public BaseSpeakerListener
  102. {
  103. public:
  104. SpeakerAddListener(LLParticipantList& parent) : BaseSpeakerListener(parent) {}
  105. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  106. };
  107. class SpeakerRemoveListener : public BaseSpeakerListener
  108. {
  109. public:
  110. SpeakerRemoveListener(LLParticipantList& parent) : BaseSpeakerListener(parent) {}
  111. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  112. };
  113. class SpeakerClearListener : public BaseSpeakerListener
  114. {
  115. public:
  116. SpeakerClearListener(LLParticipantList& parent) : BaseSpeakerListener(parent) {}
  117. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  118. };
  119. class SpeakerModeratorUpdateListener : public BaseSpeakerListener
  120. {
  121. public:
  122. SpeakerModeratorUpdateListener(LLParticipantList& parent) : BaseSpeakerListener(parent) {}
  123. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  124. };
  125. class SpeakerMuteListener : public BaseSpeakerListener
  126. {
  127. public:
  128. SpeakerMuteListener(LLParticipantList& parent) : BaseSpeakerListener(parent) {}
  129. /*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
  130. };
  131. /**
  132. * Menu used in the participant list.
  133. */
  134. class LLParticipantListMenu : public LLListContextMenu
  135. {
  136. public:
  137. LLParticipantListMenu(LLParticipantList& parent):mParent(parent){};
  138. /*virtual*/ LLContextMenu* createMenu();
  139. /*virtual*/ void show(LLView* spawning_view, const uuid_vec_t& uuids, S32 x, S32 y);
  140. protected:
  141. LLParticipantList& mParent;
  142. private:
  143. bool enableContextMenuItem(const LLSD& userdata);
  144. bool enableModerateContextMenuItem(const LLSD& userdata);
  145. bool checkContextMenuItem(const LLSD& userdata);
  146. void sortParticipantList(const LLSD& userdata);
  147. void toggleAllowTextChat(const LLSD& userdata);
  148. void toggleMute(const LLSD& userdata, U32 flags);
  149. void toggleMuteText(const LLSD& userdata);
  150. void toggleMuteVoice(const LLSD& userdata);
  151. /**
  152. * Return true if Agent is group moderator(and moderator of group call).
  153. */
  154. bool isGroupModerator();
  155. // Voice moderation support
  156. /**
  157. * Check whether specified by argument avatar is muted for group chat or not.
  158. */
  159. bool isMuted(const LLUUID& avatar_id);
  160. /**
  161. * Processes Voice moderation menu items.
  162. *
  163. * It calls either moderateVoiceParticipant() or moderateVoiceParticipant() depend on
  164. * passed parameter.
  165. *
  166. * @param userdata can be "selected" or "others".
  167. *
  168. * @see moderateVoiceParticipant()
  169. * @see moderateVoiceAllParticipants()
  170. */
  171. void moderateVoice(const LLSD& userdata);
  172. /**
  173. * Mutes/Unmutes avatar for current group voice chat.
  174. *
  175. * It only marks avatar as muted for session and does not use local Agent's Block list.
  176. * It does not mute Agent itself.
  177. *
  178. * @param[in] avatar_id UUID of avatar to be processed
  179. * @param[in] unmute if true - specified avatar will be muted, otherwise - unmuted.
  180. *
  181. * @see moderateVoiceAllParticipants()
  182. */
  183. void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute);
  184. /**
  185. * Mutes/Unmutes all avatars for current group voice chat.
  186. *
  187. * It only marks avatars as muted for session and does not use local Agent's Block list.
  188. *
  189. * @param[in] unmute if true - avatars will be muted, otherwise - unmuted.
  190. *
  191. * @see moderateVoiceParticipant()
  192. */
  193. void moderateVoiceAllParticipants(bool unmute);
  194. static void confirmMuteAllCallback(const LLSD& notification, const LLSD& response);
  195. };
  196. /**
  197. * Comparator for comparing avatar items by last spoken time
  198. */
  199. class LLAvatarItemRecentSpeakerComparator : public LLAvatarItemNameComparator, public LLRefCount
  200. {
  201. LOG_CLASS(LLAvatarItemRecentSpeakerComparator);
  202. public:
  203. LLAvatarItemRecentSpeakerComparator(LLParticipantList& parent):mParent(parent){};
  204. virtual ~LLAvatarItemRecentSpeakerComparator() {};
  205. protected:
  206. virtual bool doCompare(const LLAvatarListItem* avatar_item1, const LLAvatarListItem* avatar_item2) const;
  207. private:
  208. LLParticipantList& mParent;
  209. };
  210. private:
  211. void onAvatarListDoubleClicked(LLUICtrl* ctrl);
  212. void onAvatarListRefreshed(LLUICtrl* ctrl, const LLSD& param);
  213. void onAvalineCallerFound(const LLUUID& participant_id);
  214. void onAvalineCallerRemoved(const LLUUID& participant_id);
  215. /**
  216. * Adjusts passed participant to work properly.
  217. *
  218. * Adds SpeakerMuteListener to process moderation actions.
  219. */
  220. void adjustParticipant(const LLUUID& speaker_id);
  221. bool isHovered();
  222. LLSpeakerMgr* mSpeakerMgr;
  223. LLAvatarList* mAvatarList;
  224. std::set<LLUUID> mModeratorList;
  225. std::set<LLUUID> mModeratorToRemoveList;
  226. LLPointer<SpeakerAddListener> mSpeakerAddListener;
  227. LLPointer<SpeakerRemoveListener> mSpeakerRemoveListener;
  228. LLPointer<SpeakerClearListener> mSpeakerClearListener;
  229. LLPointer<SpeakerModeratorUpdateListener> mSpeakerModeratorListener;
  230. LLPointer<SpeakerMuteListener> mSpeakerMuteListener;
  231. LLParticipantListMenu* mParticipantListMenu;
  232. /**
  233. * This field manages an adding a new avatar_id in the mAvatarList
  234. * If true, then agent_id wont be added into mAvatarList
  235. * Also by default this field is controlling a sort procedure, @c sort()
  236. */
  237. bool mExcludeAgent;
  238. // boost::connections
  239. boost::signals2::connection mAvatarListDoubleClickConnection;
  240. boost::signals2::connection mAvatarListRefreshConnection;
  241. boost::signals2::connection mAvatarListReturnConnection;
  242. boost::signals2::connection mAvatarListToggleIconsConnection;
  243. LLPointer<LLAvatarItemRecentSpeakerComparator> mSortByRecentSpeakers;
  244. validate_speaker_callback_t mValidateSpeakerCallback;
  245. LLAvalineUpdater* mAvalineUpdater;
  246. };
  247. #endif // LL_PARTICIPANTLIST_H