Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.parser.common;
  23. /**
  24. * Contains User information.
  25. *
  26. * @author Shane Mc Cormack
  27. * @author Chris Smith
  28. * @see IRCParser
  29. */
  30. public class MyInfo {
  31. /** Character to prepend to nickname if in use (Default "_"). */
  32. private char prependChar = '_';
  33. /** Nickname to attempt to use on IRC. */
  34. private String nickname;
  35. /**
  36. * Alternative nickname to attempt to use on IRC. If the first nickname is
  37. * in use, and a NickInUse message is recieved before 001, we will attempt
  38. * to use this nickname instead.<br>
  39. * If this also fails, we will start prepending the prependChar character
  40. * (_) to the main nickname
  41. */
  42. private String altNickname;
  43. /** Realname string to use. */
  44. private String realname;
  45. /** Username to use, this doesn't matter when an ident server is running. */
  46. private String username;
  47. /**
  48. * Create a new MyInfo object.
  49. */
  50. public MyInfo() {
  51. String result;
  52. try {
  53. result = System.getProperty("user.name");
  54. } catch (final SecurityException e) {
  55. result = null;
  56. }
  57. if (result == null || result.isEmpty()) {
  58. nickname = "IRCParser";
  59. username = "IRCParser";
  60. realname = "DMDIrc IRCParser";
  61. altNickname = "IRC-Parser";
  62. } else {
  63. nickname = result;
  64. username = nickname;
  65. realname = nickname + " - DMDIrc";
  66. altNickname = nickname + "-";
  67. }
  68. }
  69. /**
  70. * Set the Nickname.
  71. *
  72. * @param newValue Value to set to.
  73. */
  74. public void setNickname(final String newValue) {
  75. if (newValue != null && !newValue.isEmpty()) {
  76. nickname = newValue;
  77. }
  78. }
  79. /**
  80. * Get the Nickname.
  81. *
  82. * @return Current Nickname
  83. */
  84. public String getNickname() {
  85. return nickname;
  86. }
  87. /**
  88. * Set the Alternative Nickname.
  89. *
  90. * @param newValue Value to set to.
  91. */
  92. public void setAltNickname(final String newValue) {
  93. if (newValue != null && !newValue.isEmpty()) {
  94. altNickname = newValue;
  95. }
  96. }
  97. /**
  98. * Get the Alternative Nickname.
  99. *
  100. * @return Current Nickname
  101. */
  102. public String getAltNickname() {
  103. return altNickname;
  104. }
  105. /**
  106. * Set the Realname.
  107. *
  108. * @param newValue Value to set to.
  109. */
  110. public void setRealname(final String newValue) {
  111. if (newValue != null && !newValue.isEmpty()) {
  112. realname = newValue;
  113. }
  114. }
  115. /**
  116. * Get the Realname.
  117. *
  118. * @return Current Realname
  119. */
  120. public String getRealname() {
  121. return realname;
  122. }
  123. /**
  124. * Set the Username.
  125. *
  126. * @param newValue Value to set to.
  127. */
  128. public void setUsername(final String newValue) {
  129. if (newValue != null && !newValue.isEmpty()) {
  130. username = newValue;
  131. }
  132. }
  133. /**
  134. * Get the Username.
  135. *
  136. * @return Current Username
  137. */
  138. public String getUsername() {
  139. return username;
  140. }
  141. /**
  142. * Set the Prepend Character.
  143. *
  144. * @param newValue Value to set to.
  145. */
  146. public void setPrependChar(final char newValue) {
  147. prependChar = newValue;
  148. }
  149. /**
  150. * Get the Prepend Character.
  151. *
  152. * @return Current Prepend Character
  153. */
  154. public char getPrependChar() {
  155. return prependChar;
  156. }
  157. }