1 /*****************************************************/
2 /* This java file is a part of the */
4 /* - Plouf's Java IRC Client - */
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
8 /* All contacts : theplouf@yahoo.com */
10 /* PJIRC is free software; you can redistribute */
11 /* it and/or modify it under the terms of the GNU */
12 /* General Public License as published by the */
13 /* Free Software Foundation; version 2 or later of */
16 /* PJIRC is distributed in the hope that it will */
17 /* be useful, but WITHOUT ANY WARRANTY; without */
18 /* even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
20 /* General Public License for more details. */
22 /* You should have received a copy of the GNU */
23 /* General Public License along with PJIRC; if */
24 /* not, write to the Free Software Foundation, */
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
26 /* MA 02111-1307 USA */
28 /*****************************************************/
33 import irc.ReplyServerListener;
35 import irc.StatusListener;
40 public class AWTStatus extends BaseAWTSource implements StatusListener, ReplyServerListener {
43 * Create a new AWTStatus.
46 * global irc configuration.
50 public AWTStatus(PixxConfiguration config, Status s) {
52 s.addStatusListener(this);
53 s.getIRCServer().addReplyServerListener(this);
58 public void release() {
59 ((Status) _source).removeStatusListener(this);
60 ((Status) _source).getIRCServer().removeReplyServerListener(this);
64 private String getSourceName() {
65 if (!_pixxConfiguration.getIRCConfiguration().getB("multiserver")) {
66 if (_pixxConfiguration.getIRCConfiguration().getB("useinfo"))
67 return getText(PixxTextProvider.SOURCE_INFO);
68 return getText(PixxTextProvider.SOURCE_STATUS);
71 return ((Status) _source).getServerName();
74 private void title() {
75 setTitle(getSourceName() + ": " + ((Status) _source).getNick() + " [" + ((Status) _source).getMode() + "]");
79 public String getShortTitle() {
80 return getSourceName();
84 * A notice has been received.
91 public void noticeReceived(String from, String msg) {
92 print("-" + from + "- " + msg, 5);
96 public void nickChanged(String nick, Status status) {
97 print("*** " + getText(PixxTextProvider.SOURCE_YOUR_NICK, nick), 3);
102 public void modeChanged(String mode, Status status) {
103 if (mode.length() > 0)
104 print("*** " + getText(PixxTextProvider.SOURCE_YOUR_MODE, mode), 3);
109 public void invited(String channel, String who, Status status) {
110 if (status.getIRCServer().getDefaultSource() != null)
111 status.getIRCServer().getDefaultSource().report(getText(PixxTextProvider.SOURCE_YOU_INVITED, who, channel));
115 public Boolean replyReceived(String prefix, String id, String params[], IRCServer server) {
116 if (id.equals("301")) // away
118 String toSend = getText(PixxTextProvider.SOURCE_AWAY, params[1]) + " :";
119 for (int i = 2; i < params.length; i++)
120 toSend += " " + params[i];
121 _source.report(toSend);
123 return Boolean.FALSE;