Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

XmppFakeChannel.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2006-2017 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.parser.xmpp;
  23. import com.dmdirc.parser.common.BaseChannelInfo;
  24. import com.dmdirc.parser.common.ChannelListModeItem;
  25. import com.dmdirc.parser.events.ChannelNamesEvent;
  26. import com.dmdirc.parser.interfaces.ChannelClientInfo;
  27. import com.dmdirc.parser.interfaces.ClientInfo;
  28. import com.dmdirc.parser.interfaces.Parser;
  29. import java.time.LocalDateTime;
  30. import java.util.Collection;
  31. /**
  32. * A 'fake' local channel used to display buddy lists.
  33. */
  34. public class XmppFakeChannel extends BaseChannelInfo {
  35. /**
  36. * Creates a new fake channel belonging to the specified parser and with the given name.
  37. *
  38. * @param parser The XMPP parser that owns this channel
  39. * @param name The name of the channel
  40. */
  41. public XmppFakeChannel(final Parser parser, final String name) {
  42. super(parser, name);
  43. }
  44. @Override
  45. public void setTopic(final String topic) {
  46. throw new UnsupportedOperationException("Not supported yet.");
  47. }
  48. @Override
  49. public String getTopic() {
  50. return "No topic yet!";
  51. }
  52. @Override
  53. public long getTopicTime() {
  54. return System.currentTimeMillis(); // TODO
  55. }
  56. @Override
  57. public String getTopicSetter() {
  58. return ""; // TODO
  59. }
  60. @Override
  61. public String getModes() {
  62. return ""; // TODO
  63. }
  64. @Override
  65. public String getMode(final char mode) {
  66. throw new UnsupportedOperationException("Not supported yet.");
  67. }
  68. @Override
  69. public Collection<ChannelListModeItem> getListMode(final char mode) {
  70. throw new UnsupportedOperationException("Not supported yet.");
  71. }
  72. @Override
  73. public void part(final String reason) {
  74. throw new UnsupportedOperationException("Not supported yet.");
  75. }
  76. @Override
  77. public void sendWho() {
  78. throw new UnsupportedOperationException("Not supported yet.");
  79. }
  80. @Override
  81. public void alterMode(final boolean add, final Character mode, final String parameter) {
  82. throw new UnsupportedOperationException("Not supported yet.");
  83. }
  84. @Override
  85. public void flushModes() {
  86. throw new UnsupportedOperationException("Not supported yet.");
  87. }
  88. @Override
  89. public void requestListModes() {
  90. throw new UnsupportedOperationException("Not supported yet.");
  91. }
  92. @Override
  93. public ChannelClientInfo getChannelClient(final ClientInfo client) {
  94. return getClient(client.getNickname());
  95. }
  96. @Override
  97. public ChannelClientInfo getChannelClient(final String client, final boolean create) {
  98. final String[] parts = getParser().parseHostmask(client);
  99. if (create && getClient(parts[0]) == null) {
  100. return new XmppChannelClientInfo(this, getParser().getClient(client));
  101. }
  102. return getClient(parts[0]);
  103. }
  104. /**
  105. * Updates this channel with the specified contacts.
  106. *
  107. * @param clients The contacts to be added
  108. */
  109. public void updateContacts(final Collection<XmppClientInfo> clients) {
  110. for (XmppClientInfo client : clients) {
  111. addClient(client.getNickname(), new XmppChannelClientInfo(this, client));
  112. }
  113. // TODO: Delete old contacts, don't needlessly create new objects
  114. getParser().getCallbackManager().publish(
  115. new ChannelNamesEvent(getParser(), LocalDateTime.now(), this));
  116. }
  117. }