1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
35 public class Query extends IRCSource implements ReplyServerListener {
\r
36 private String _nick;
\r
37 private String _whois;
\r
39 private ListenerGroup _listeners;
\r
42 * Create a new Query.
\r
45 * global irc configuration.
\r
51 public Query(IRCConfiguration config, String nick, IRCServer s) {
\r
53 s.addReplyServerListener(this);
\r
54 _listeners = new ListenerGroup();
\r
57 if (_ircConfiguration.getASLMaster())
\r
58 getIRCServer().execute("WHOIS " + _nick);
\r
59 setInterpretor(new QueryInterpretor(config));
\r
63 public void release() {
\r
64 ((IRCServer) _server).removeReplyServerListener(this);
\r
74 public void addQueryListener(QueryListener lis) {
\r
75 _listeners.addListener(lis);
\r
79 * Remove a listener.
\r
82 * listener to remove.
\r
84 public void removeQueryListeners(QueryListener lis) {
\r
85 _listeners.removeListener(lis);
\r
89 public String getType() {
\r
94 public String getName() {
\r
99 * Get whois information for remote nick.
\r
101 * @return peer whois information.
\r
103 public String getWhois() {
\r
108 public boolean talkable() {
\r
113 public void leave() {
\r
114 getIRCServer().leaveQuery(getName());
\r
118 * Notify this query the remote nick has changed.
\r
123 public void changeNick(String newNick) {
\r
125 _listeners.sendEvent("nickChanged", newNick, this);
\r
129 public Boolean replyReceived(String prefix, String id, String params[], IRCServer server) {
\r
130 if (id.equals("311")) {
\r
131 if (params[1].toLowerCase(java.util.Locale.ENGLISH).equals(_nick.toLowerCase(java.util.Locale.ENGLISH))) {
\r
132 String name = params[params.length - 1];
\r
134 _listeners.sendEvent("whoisChanged", _whois, this);
\r
137 return Boolean.FALSE;
\r