您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

MSNLocalClientInfo.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2006-2013 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.addons.parser_msn;
  23. import com.dmdirc.parser.interfaces.LocalClientInfo;
  24. import net.sf.jml.MsnOwner;
  25. import net.sf.jml.MsnUserStatus;
  26. /**
  27. * A representation of the local MSN client.
  28. */
  29. public class MSNLocalClientInfo extends MSNClientInfo implements LocalClientInfo {
  30. /** MSN user. */
  31. private final MsnOwner owner;
  32. /**
  33. * Creates a new local client info object with the specified details.
  34. *
  35. * @param owner The client this object represents
  36. * @param parser The parser that owns this client info object
  37. * @param nick The nickname of the user this object represents
  38. * @param user The username of the user this object represents
  39. * @param host The hostname of the user this object represents
  40. */
  41. public MSNLocalClientInfo(final MsnOwner owner, final MSNParser parser,
  42. final String nick, final String user, final String host) {
  43. super(owner, parser, nick, user, host);
  44. this.owner = owner;
  45. }
  46. /** {@inheritDoc} */
  47. @Override
  48. public void setNickname(final String name) {
  49. owner.setDisplayName(name);
  50. }
  51. /** {@inheritDoc} */
  52. @Override
  53. public String getModes() {
  54. return "";
  55. }
  56. /** {@inheritDoc} */
  57. @Override
  58. public void setAway(final String reason) {
  59. if ("Busy".equalsIgnoreCase(reason)) {
  60. owner.setStatus(MsnUserStatus.BUSY);
  61. } else if ("Idle".equalsIgnoreCase(reason)) {
  62. owner.setStatus(MsnUserStatus.IDLE);
  63. } else if ("BRB".equalsIgnoreCase(reason)) {
  64. owner.setStatus(MsnUserStatus.BE_RIGHT_BACK);
  65. } else if ("Be Right Back".equalsIgnoreCase(reason)) {
  66. owner.setStatus(MsnUserStatus.BE_RIGHT_BACK);
  67. } else if ("phone".equalsIgnoreCase(reason)) {
  68. owner.setStatus(MsnUserStatus.ON_THE_PHONE);
  69. } else if ("on the phone".equalsIgnoreCase(reason)) {
  70. owner.setStatus(MsnUserStatus.ON_THE_PHONE);
  71. } else if ("on phone".equalsIgnoreCase(reason)) {
  72. owner.setStatus(MsnUserStatus.ON_THE_PHONE);
  73. } else if ("Out to lunch".equalsIgnoreCase(reason)) {
  74. owner.setStatus(MsnUserStatus.OUT_TO_LUNCH);
  75. } else if ("Lunch".equalsIgnoreCase(reason)) {
  76. owner.setStatus(MsnUserStatus.OUT_TO_LUNCH);
  77. } else if ("Hide".equalsIgnoreCase(reason)) {
  78. owner.setStatus(MsnUserStatus.HIDE);
  79. } else {
  80. owner.setStatus(MsnUserStatus.AWAY);
  81. }
  82. }
  83. /** {@inheritDoc} */
  84. @Override
  85. public void setBack() {
  86. owner.setStatus(MsnUserStatus.ONLINE);
  87. }
  88. /** {@inheritDoc} */
  89. @Override
  90. public void alterMode(final boolean add, final Character mode) {
  91. //Ignore
  92. }
  93. /** {@inheritDoc} */
  94. @Override
  95. public void flushModes() {
  96. //Ignore
  97. }
  98. }