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 java.util.Hashtable;
23  import java.util.Iterator;
24  
25  import org.xnap.chat.ChatManager;
26  
27  import com.limegroup.gnutella.chat.Chatter;
28  
29  public class LimeWireChatManager {
30      
31      //--- Constant(s) ---
32  
33      //--- Data field(s) ---
34  
35  	private Hashtable channelByChatter = new Hashtable();
36  	private LimeWireServant localPeer = new LimeWireServant("localhost");
37  
38      //--- Constructor(s) ---
39      
40      public LimeWireChatManager()
41      {
42      }
43  
44      //--- Method(s) ---
45  
46  	public LimeWireChatChannel getChannel(Chatter chatter)
47  	{
48  		LimeWireChatChannel channel 
49  			= (LimeWireChatChannel)channelByChatter.get(chatter);
50  		if (channel == null) {
51  			channel = new LimeWireChatChannel(chatter);
52  			ChatManager.getInstance().add(channel);
53  			channelByChatter.put(chatter, channel);
54  		}
55  		return channel;
56  	}
57  
58  	public LimeWireServant getLocalPeer()
59  	{
60  		return localPeer;
61  	}
62  
63  	public void removeAll()
64  	{
65  		for (Iterator i = channelByChatter.values().iterator(); 
66  			 i.hasNext();) {
67  			ChatManager.getInstance().remove
68  				((LimeWireChatChannel)i.next());
69  		}
70  	}
71      
72  }