View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.chat;
21  
22  import javax.swing.Action;
23  import javax.swing.Icon;
24  
25  import org.xnap.cmdl.Command;
26  import org.xnap.peer.Peer;
27  
28  /***
29   * Defines the requirements for classes that provide chat functionality. 
30   * Peers can join a channel in order to broadcast messages to 
31   * all joined peers.
32   */
33  public interface Channel extends ChannelInfo {
34  
35      //--- Constant(s) ---
36  
37      /***
38       * Send away messages in this interval.
39       */
40      long AWAY_MESSAGE_INTERVAL = 20 * 1000;
41  
42      //--- Method(s) ---
43  
44      /***
45       * Adds <code>listener</code> to the channel.
46       */
47      void addChannelListener(ChannelListener listener);
48      
49      /***
50       * Invoked by the {@link ChatManager} when the channel is removed.
51       */
52      void close();
53  
54      /***
55       * Returns an array of actions that can be performed on the channel.
56       */
57      Action[] getActions();
58  
59      /***
60       * Returns an array of commands that can be executed on the channel.
61       */
62      Command[] getCommands();
63  
64      /***
65       * Returns a 16x16 icon that is displayed in the tab title.
66       */
67      Icon getIcon();
68  
69      /***
70       * Returns an array of peer specific actions.
71       *
72       * <p>This can be used to implement channel operations like "op".
73       */
74      Action[] getPeerActions(Peer peer);
75  
76      /***
77       * Returns a reference to the chat provider. 
78  	 *
79  	 * @return null, if the channel has no provider; the provider, otherwise
80       */
81      ChatProvider getProvider();
82  
83      /***
84       * Returns an array of peers that have joined this channel.
85       */
86      Peer[] getPeers();
87  
88      /***
89       * Returns a name prefix for <code>peer</code>. This can be used to
90       * display mods.
91       */
92      String getPrefix(Peer peer);
93  
94      /***
95       * Returns true, if <code>peer</peer> is the local peer. XNap does
96       * not beep if messages are received from local peers.
97  	 */
98      boolean isLocal(Peer peer);
99  
100 	/***
101 	 * Returns true, if the channel is joined.
102 	 */
103 	boolean isJoined();
104 
105     /***
106      * Removes <code>listener</code> from the channel.
107      */
108     void removeChannelListener(ChannelListener listener);
109 
110     /***
111      * Sends a message to this channel.
112      */
113     void sendMessage(String message);
114 
115 }