1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
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      
32  
33      
34  
35  	private Hashtable channelByChatter = new Hashtable();
36  	private LimeWireServant localPeer = new LimeWireServant("localhost");
37  
38      
39      
40      public LimeWireChatManager()
41      {
42      }
43  
44      
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  }