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.plugin.limewire;
21  
22  import javax.swing.Action;
23  
24  import org.xnap.chat.AbstractChannel;
25  import org.xnap.chat.ChatProvider;
26  import org.xnap.peer.Peer;
27  
28  import com.limegroup.gnutella.chat.Chatter;
29  
30  /***
31   * Implements a limewire search session.
32   */
33  public class LimeWireChatChannel extends AbstractChannel  {
34  
35      // --- Constants(s) ---
36  
37      //--- Data Field(s) ---
38  
39  	private LimeWireServant remotePeer;
40  
41  	private Chatter chatter;
42  
43      //--- Constructor(s) ---
44  
45  	public LimeWireChatChannel(Chatter chatter)
46  	{
47  		super(chatter.getHost());
48  		
49  		this.chatter = chatter;
50  		this.remotePeer 
51  			= new LimeWireServant(chatter.getHost(), chatter.getPort());
52  		
53  		add(LimeWirePlugin.getChatManager().getLocalPeer());
54  		add(remotePeer);
55  	}
56  
57      // --- Method(s) ---
58  
59  	/***
60  	 *  @see xnap.chat.Channel#close()
61  	 */
62  	public void close() 
63  	{
64  
65  	}
66  
67  	/***
68  	 *  @see xnap.chat.Channel#getActions()
69  	 */
70  	public Action[] getActions() {
71  		return null;
72  	}
73  
74  	/***
75  	 *  @see xnap.chat.Channel#getPeerActions(xnap.peer.Peer)
76  	 */
77  	public Action[] getPeerActions(Peer peer) 
78  	{
79  		return null;
80  	}
81  
82  	/***
83  	 *  @see xnap.chat.Channel#getProvider()
84  	 */
85  	public ChatProvider getProvider() 
86  	{
87  		return null;
88  	}
89  
90  	public LimeWireServant getRemotePeer()
91  	{
92  		return remotePeer;
93  	}
94  
95  	/***
96  	 *  @see xnap.chat.Channel#isLocal(xnap.peer.Peer)
97  	 */
98  	public boolean isLocal(Peer peer) 
99  	{
100 		return peer == LimeWirePlugin.getChatManager().getLocalPeer();
101 	}
102 
103 	/***
104 	 *  @see xnap.chat.Channel#isJoined()
105 	 */
106 	public boolean isJoined() 
107 	{
108 		return false;
109 	}
110 
111 	/***
112 	 *  @see xnap.chat.Channel#sendMessage(java.lang.String)
113 	 */
114 	public void sendMessage(String message) 
115 	{
116 		chatter.send(message);
117 		// copy to self
118 		messageReceived(LimeWirePlugin.getChatManager().getLocalPeer(),
119 						message);
120 	}
121 
122 }
123