You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GroupChat.java 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.interfaces;
  23. import com.dmdirc.DMDircMBassador;
  24. import com.dmdirc.Topic;
  25. import com.dmdirc.parser.common.ChannelListModeItem;
  26. import java.util.Collection;
  27. import java.util.List;
  28. import java.util.Optional;
  29. import javax.annotation.Nullable;
  30. /**
  31. * A chat containing multiple participants.
  32. */
  33. public interface GroupChat extends Chat {
  34. /**
  35. * Returns the current topic for this channel.
  36. *
  37. * @return Current channel topic
  38. */
  39. Optional<Topic> getCurrentTopic();
  40. /**
  41. * Gets an event bus which will only contain events generated in relation to this channel.
  42. *
  43. * @return An event bus scoped to this channel.
  44. */
  45. DMDircMBassador getEventBus();
  46. /**
  47. * Retrieves the maximum length that a topic on this channel can be.
  48. *
  49. * @return The maximum length that this channel's topic may be
  50. */
  51. int getMaxTopicLength();
  52. /**
  53. * Refreshes the list of clients stored by this channel. Should be called when (visible) user
  54. * modes or nicknames change.
  55. */
  56. // TODO: Should probably not need this.
  57. void refreshClients();
  58. /**
  59. * Retrieve the topics that have been seen on this channel.
  60. *
  61. * @return A list of topics that have been seen on this channel, including the current one.
  62. */
  63. List<Topic> getTopics();
  64. /**
  65. * Determines if we are currently joined to the chat.
  66. *
  67. * @return True if joined, false otherwise.
  68. */
  69. boolean isOnChannel();
  70. /**
  71. * Joins the specified channel. This only makes sense if used after a call to part().
  72. */
  73. void join();
  74. /**
  75. * Parts this channel with the specified message. Parting does NOT close the channel window.
  76. *
  77. * @param reason The reason for parting the channel
  78. */
  79. void part(String reason);
  80. /**
  81. * Requests all available list modes for this channel.
  82. */
  83. void retrieveListModes();
  84. /**
  85. * Attempts to set the topic of this channel.
  86. *
  87. * @param topic The new topic to be used. An empty string will clear the current topic
  88. */
  89. void setTopic(String topic);
  90. /**
  91. * Gets the name of the chat.
  92. *
  93. * @return The current name of the group chat.
  94. */
  95. String getName();
  96. /**
  97. * Tries to retrieve a {@link GroupChatUser} from the current {@link GroupChat} for the
  98. * specified {@link User}.
  99. *
  100. * @param user User to find
  101. *
  102. * @return User on channel, or empty if the user is not on the channel
  103. */
  104. Optional<GroupChatUser> getUser(User user);
  105. /**
  106. * Returns the users available on this GroupChat.
  107. *
  108. * @return Users in the GroupChat
  109. */
  110. Collection<GroupChatUser> getUsers();
  111. /**
  112. * Kicks the specified user, optionally with the specified message.
  113. *
  114. * @param user User to kick
  115. * @param reason Reason for the kick
  116. */
  117. void kick(GroupChatUser user, Optional<String> reason);
  118. /**
  119. * Gets the items in the specified list mode category.
  120. *
  121. * @param mode The list mode to retrieve items for.
  122. * @return The known mode entries.
  123. */
  124. // TODO: Return a parser-neutral type
  125. // TODO: Don't assume mode types are always chars, use an abstraction
  126. Collection<ChannelListModeItem> getListModeItems(char mode);
  127. /**
  128. * Sets a mode on the group chat.
  129. *
  130. * @param mode The mode to set.
  131. * @param value The value of the mode, if any.
  132. */
  133. void setMode(char mode, @Nullable String value);
  134. /**
  135. * Unsets a mode on the group chat.
  136. *
  137. * @param mode The mode to unset.
  138. * @param value The value of the mode, if any.
  139. */
  140. void removeMode(char mode, String value);
  141. /**
  142. * Flushes all pending mode changes.
  143. */
  144. // TODO: Add a builder-type interface for batch mode changes, instead of add+flush.
  145. void flushModes();
  146. /**
  147. * Gets boolean modes for this chat.
  148. *
  149. * @return The current boolean (toggleable) modes.
  150. */
  151. // TODO: Don't use a String here, return a collection of some abstraction.
  152. String getModes();
  153. /**
  154. * Gets the value of the given mode for this chat.
  155. *
  156. * @param mode The mode to retrieve.
  157. * @return The current value of the mode.
  158. */
  159. String getModeValue(final char mode);
  160. /**
  161. * Requests information about all the {@link User}s in this GroupChat.
  162. */
  163. void requestUsersInfo();
  164. }