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.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.dmdirc.ktirc.model
  2. import com.dmdirc.ktirc.io.CaseMapping
  3. /**
  4. * Describes the state of a channel that the client has joined.
  5. */
  6. class ChannelState(val name: String, caseMappingProvider: () -> CaseMapping) {
  7. /**
  8. * Whether or not we are in the process of receiving a user list (which may span many messages).
  9. */
  10. var receivingUserList = false
  11. internal set
  12. /**
  13. * Whether or not we have discovered the full set of modes for the channel.
  14. */
  15. var modesDiscovered = false
  16. internal set
  17. /**
  18. * A map of all users in the channel to their current modes.
  19. */
  20. val users = ChannelUserMap(caseMappingProvider)
  21. /**
  22. * A map of modes set on the channel, and their values (if any).
  23. *
  24. * If [modesDiscovered] is false, this map may be missing modes that the server hasn't told us about.
  25. */
  26. var modes = HashMap<Char, String>()
  27. }
  28. /**
  29. * Describes a user in a channel, and their modes.
  30. */
  31. data class ChannelUser(var nickname: String, var modes: String = "")
  32. /**
  33. * The types of supported channel modes, and what parameters they require.
  34. *
  35. * These must be sorted according to the order they are sent in the CHANMODES server feature.
  36. */
  37. enum class ChannelModeType {
  38. /** The mode adds or removes an entry for a list. It must have a param to add or remove. */
  39. List,
  40. /** The mode has a parameter that must be present to set it or unset it. */
  41. SetUnsetParameter,
  42. /** The mode has a parameter that must be present to set it, but is unset without one. */
  43. SetParameter,
  44. /** The mode does not take parameters in any case. */
  45. NoParameter;
  46. /**
  47. * Whether this mode requires a parameter to be set or not.
  48. */
  49. val needsParameterToSet: Boolean
  50. get() = this != NoParameter
  51. /**
  52. * Whether this mode requires a parameter to be unset or not.
  53. */
  54. val needsParameterToUnset: Boolean
  55. get() = this != NoParameter && this != SetParameter
  56. }