1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
36
37 /***
38 * Send away messages in this interval.
39 */
40 long AWAY_MESSAGE_INTERVAL = 20 * 1000;
41
42
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 }