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.io.File;
23  
24  import org.xnap.XNap;
25  import org.xnap.gui.Dialogs;
26  
27  import com.limegroup.gnutella.ActivityCallback;
28  import com.limegroup.gnutella.Connection;
29  import com.limegroup.gnutella.Downloader;
30  import com.limegroup.gnutella.Endpoint;
31  import com.limegroup.gnutella.FileDesc;
32  import com.limegroup.gnutella.GUID;
33  import com.limegroup.gnutella.ManagedConnection;
34  import com.limegroup.gnutella.RemoteFileDesc;
35  import com.limegroup.gnutella.Uploader;
36  import com.limegroup.gnutella.chat.Chatter;
37  import com.limegroup.gnutella.search.HostData;
38  import com.limegroup.gnutella.security.User;
39  import com.sun.java.util.collections.Set;
40  
41  /***
42   * @author warper
43   *
44   * To change the template for this generated type comment go to
45   * Window>Preferences>Java>Code Generation>Code and Comments
46   */
47  public class LimeWireCallback implements ActivityCallback {
48  
49  	/***
50  	 *  @see com.limegroup.gnutella.ActivityCallback#connectionInitializing(com.limegroup.gnutella.Connection)
51  	 */
52  	public void connectionInitializing(Connection c) 
53  	{
54  		if (c instanceof ManagedConnection) {
55  			LimeWirePanel p = LimeWirePlugin.getConnectionPanel();
56  			if (p != null) {
57  				p.getTableModel().add((ManagedConnection)c);
58  			}
59  		}
60  	}
61  
62  	/***
63  	 *  @see com.limegroup.gnutella.ActivityCallback#connectionInitialized(com.limegroup.gnutella.Connection)
64  	 */
65  	public void connectionInitialized(Connection c) 
66  	{
67  		// notify status panel
68  		LimeWirePlugin.updateStatusPanel();
69  	}
70  
71  	/***
72  	 *  @see com.limegroup.gnutella.ActivityCallback#connectionClosed(com.limegroup.gnutella.Connection)
73  	 */
74  	public void connectionClosed(Connection c) 
75  	{
76  		if (c instanceof ManagedConnection) {
77  			LimeWirePanel p = LimeWirePlugin.getConnectionPanel();
78  			if (p != null) {
79  				p.getTableModel().remove((ManagedConnection)c);
80  			}
81  		}
82  		
83  		// notify status panel
84  		LimeWirePlugin.updateStatusPanel();
85  	}
86  
87  	/***
88  	 *  @see com.limegroup.gnutella.ActivityCallback#knownHost(com.limegroup.gnutella.Endpoint)
89  	 */
90  	public void knownHost(Endpoint arg0) {
91  
92  	}
93  
94  	/***
95  	 *  @see com.limegroup.gnutella.ActivityCallback#handleQueryResult(com.limegroup.gnutella.search.HostData, com.limegroup.gnutella.Response, com.sun.java.util.collections.List)
96  	 */
97  	public void handleQueryResult(RemoteFileDesc file, HostData data, 
98  								  Set locations) 
99  	{
100 		LimeWirePlugin.getSearchManager().received(file, data, locations);
101 	}
102 
103 	/***
104 	 *  @see com.limegroup.gnutella.ActivityCallback#handleQueryString(java.lang.String)
105 	 */
106 	public void handleQueryString(String arg0) {
107 
108 	}
109 
110 	/***
111 	 *  @see com.limegroup.gnutella.ActivityCallback#addDownload(com.limegroup.gnutella.Downloader)
112 	 */
113 	public void addDownload(Downloader d) 
114 	{
115 		LimeWirePlugin.getTransferManager().add(d);
116 	}
117 
118 	/***
119 	 *  @see com.limegroup.gnutella.ActivityCallback#removeDownload(com.limegroup.gnutella.Downloader)
120 	 */
121 	public void removeDownload(Downloader d) 
122 	{
123 		//LimeWirePlugin.getTransferManager().remove(d);
124 	}
125 
126 	/***
127 	 *  @see com.limegroup.gnutella.ActivityCallback#addUpload(com.limegroup.gnutella.Uploader)
128 	 */
129 	public void addUpload(Uploader u) 
130 	{
131 		LimeWirePlugin.getTransferManager().add(u);
132 	}
133 
134 	/***
135 	 *  @see com.limegroup.gnutella.ActivityCallback#removeUpload(com.limegroup.gnutella.Uploader)
136 	 */
137 	public void removeUpload(Uploader u) 
138 	{
139 		//LimeWirePlugin.getTransferManager().remove(u);
140 	}
141 
142 	/***
143 	 *  @see com.limegroup.gnutella.ActivityCallback#acceptChat(com.limegroup.gnutella.chat.Chatter)
144 	 */
145 	public void acceptChat(Chatter c) 
146 	{
147 		// add channel to ChatManager
148 		LimeWirePlugin.getChatManager().getChannel(c);
149 	}
150 
151 	/***
152 	 *  @see com.limegroup.gnutella.ActivityCallback#receiveMessage(com.limegroup.gnutella.chat.Chatter)
153 	 */
154 	public void receiveMessage(Chatter c) 
155 	{
156 		LimeWireChatChannel channel = LimeWirePlugin.getChatManager().getChannel(c);
157 		channel.messageReceived(channel.getRemotePeer(), c.getMessage());
158 	}
159 
160 	/***
161 	 *  @see com.limegroup.gnutella.ActivityCallback#chatUnavailable(com.limegroup.gnutella.chat.Chatter)
162 	 */
163 	public void chatUnavailable(Chatter c) 
164 	{
165 		LimeWireChatChannel channel = LimeWirePlugin.getChatManager().getChannel(c);
166 		channel.errorReceived(XNap.tr("Remote peer unavailable!"));	
167 	}
168 
169 	/***
170 	 *  @see com.limegroup.gnutella.ActivityCallback#chatErrorMessage(com.limegroup.gnutella.chat.Chatter, java.lang.String)
171 	 */
172 	public void chatErrorMessage(Chatter c, String message) 
173 	{
174 		LimeWireChatChannel channel = LimeWirePlugin.getChatManager().getChannel(c);
175 		channel.errorReceived(message);
176 	}
177 
178 	/***
179 	 *  @see com.limegroup.gnutella.ActivityCallback#browseHostFailed(com.limegroup.gnutella.GUID)
180 	 */
181 	public void browseHostFailed(GUID guid) 
182 	{
183 		LimeWirePlugin.getSearchManager().failed(guid);
184 	}
185 
186 	/***
187 	 *  @see com.limegroup.gnutella.ActivityCallback#notifyUserAboutUpdate(java.lang.String, boolean, boolean)
188 	 */
189 	public void notifyUserAboutUpdate(String arg0, boolean arg1, boolean arg2) 
190 	{
191 		// not implemented, the core is updated through the
192 		// XNap plugin facilities
193 	}
194 
195 	/***
196 	 *  @see com.limegroup.gnutella.ActivityCallback#fileManagerLoaded()
197 	 */
198 	public void fileManagerLoaded() {
199 
200 	}
201 
202 	/***
203 	 *  @see com.limegroup.gnutella.ActivityCallback#addSharedDirectory(java.io.File, java.io.File)
204 	 */
205 	public void addSharedDirectory(File arg0, File arg1) {
206 
207 	}
208 
209 	/***
210 	 *  @see com.limegroup.gnutella.ActivityCallback#addSharedFile(com.limegroup.gnutella.FileDesc, java.io.File)
211 	 */
212 	public void addSharedFile(FileDesc arg0, File arg1) {
213 
214 	}
215 
216 	/***
217 	 *  @see com.limegroup.gnutella.ActivityCallback#handleSharedFileUpdate(java.io.File)
218 	 */
219 	public void handleSharedFileUpdate(File arg0) {
220 
221 	}
222 
223 	/***
224 	 *  @see com.limegroup.gnutella.ActivityCallback#clearSharedFiles()
225 	 */
226 	public void clearSharedFiles() {
227 
228 	}
229 
230 	/***
231 	 *  @see com.limegroup.gnutella.ActivityCallback#setAnnotateEnabled(boolean)
232 	 */
233 	public void setAnnotateEnabled(boolean arg0) {
234 
235 	}
236 
237 	/***
238 	 *  @see com.limegroup.gnutella.ActivityCallback#downloadsComplete()
239 	 */
240 	public void downloadsComplete() {
241 
242 	}
243 
244 	/***
245 	 *  @see com.limegroup.gnutella.ActivityCallback#uploadsComplete()
246 	 */
247 	public void uploadsComplete() {
248 
249 	}
250 
251 	/***
252 	 *  @see com.limegroup.gnutella.ActivityCallback#getUserAuthenticationInfo(java.lang.String)
253 	 */
254 	public User getUserAuthenticationInfo(String arg0) {
255 		return null;
256 	}
257 
258 	/***
259 	 *  @see com.limegroup.gnutella.ActivityCallback#promptAboutCorruptDownload(com.limegroup.gnutella.Downloader)
260 	 */
261 	public void promptAboutCorruptDownload(Downloader arg0) {
262 
263 	}
264 
265 	/***
266 	 *  @see com.limegroup.gnutella.ActivityCallback#restoreApplication()
267 	 */
268 	public void restoreApplication() {
269 
270 	}
271 
272 	/***
273 	 *  @see com.limegroup.gnutella.ActivityCallback#showDownloads()
274 	 */
275 	public void showDownloads() {
276 
277 	}
278 
279 	/***
280 	 *  @see com.limegroup.gnutella.ActivityCallback#getHostValue(java.lang.String)
281 	 */
282 	public String getHostValue(String arg0) {
283 		return null;
284 	}
285 
286 	/***
287 	 *  @see com.limegroup.gnutella.ActivityCallback#indicateNewVersion()
288 	 */
289 	public void indicateNewVersion() {
290 	}
291 
292 	/***
293 	 *  @see com.limegroup.gnutella.ActivityCallback#showError(java.lang.String, java.lang.String)
294 	 */
295 	public void showError(String message, String messageKey) {
296 		Dialogs.error(null, message);
297 	}
298 
299 	/***
300 	 *  @see com.limegroup.gnutella.ActivityCallback#isQueryAlive(com.limegroup.gnutella.GUID)
301 	 */
302 	public boolean isQueryAlive(GUID arg0) {
303 		// is there a way to tell if query is still displayed on screen in XNap?
304 		return false;
305 	}
306 
307 	/***
308 	 *  @see com.limegroup.gnutella.ActivityCallback#componentLoading(java.lang.String)
309 	 */
310 	public void componentLoading(String arg0) {
311 	}
312 
313 }