FileDocCategorySizeDatePackage
RPDownloadManager.javaAPI DocAzureus 3.0.3.48857Thu May 31 16:28:44 BST 2007org.gudy.azureus2.pluginsimpl.remote.download

RPDownloadManager

public class RPDownloadManager extends RPObject implements DownloadManager
author
parg

Fields Summary
protected transient DownloadManager
delegate
Constructors Summary
protected RPDownloadManager(DownloadManager _delegate)

		super( _delegate );
	
Methods Summary
public RPReply_process(RPRequest request)

		String		method 	= request.getMethod();
		Object[]	params	= request.getParams();
		
		if ( method.equals( "getDownloads")){
			
			Download[]	downloads = delegate.getDownloads();
			
				// unfortunately downloads with broken torrents can exist and have no associated
				// Torrent. Easiest fix here is to filter them out.
			
			RPDownload[]	res = new RPDownload[downloads.length];
			
			for (int i=0;i<res.length;i++){
				
				res[i] = RPDownload.create( downloads[i]);
			}
			
			return( new RPReply( res ));
			
		}else if ( method.equals( "getDownloads[boolean]")){
			
			Download[]	downloads = delegate.getDownloads(((Boolean)request.getParams()[0]).booleanValue());
			
			RPDownload[]	res = new RPDownload[downloads.length];
			
			for (int i=0;i<res.length;i++){
				
				res[i] = RPDownload.create( downloads[i]);
			}
			
			return( new RPReply( res ));
						
		}else if ( method.equals( "addDownload[Torrent]" )){
		
			try{
				RPTorrent	torrent = (RPTorrent)request.getParams()[0];
				
				Download res = delegate.addDownload((Torrent)torrent._setLocal());
				
				return( new RPReply( RPDownload.create(res)));
				
			}catch( DownloadException e ){
				
				throw( new RPException("DownloadManager::addDownload failed", e ));
			}
		
		}else if ( method.equals( "addDownload[Torrent,String,String]" )){
			
			try{
				RPTorrent	torrent = (RPTorrent)request.getParams()[0];
				File		f1 = params[1]==null?null:new File((String)params[1]);
				File		f2 = params[2]==null?null:new File((String)params[2]);
				
				Download res = delegate.addDownload((Torrent)torrent._setLocal(), f1, f2 );
				
				return( new RPReply( RPDownload.create(res)));
				
			}catch( DownloadException e ){
				
				throw( new RPException("DownloadManager::addDownload failed", e ));
			}
			
		}else if ( method.equals( "addDownload[URL]" )){
				
			try{
				delegate.addDownload((URL)request.getParams()[0]);
				
			}catch( DownloadException e ){
				
				throw( new RPException("DownloadManager::addDownload failed", e ));
			}
			
			return( new RPReply( null ));
			
		}else if ( method.equals( "pauseDownloads")){
			
			delegate.pauseDownloads();
			
			return( null );
				
		}else if ( method.equals( "resumeDownloads")){
			
			delegate.resumeDownloads();
			
			return( null );
				
		}else if ( method.equals( "stopAllDownloads")){
			
			delegate.stopAllDownloads();
			
			return( null );
				
		}else if ( method.equals( "startAllDownloads")){
			
			delegate.startAllDownloads();
		
			return( null );
		}
		
		throw( new RPException( "Unknown method: " + method ));
	
protected void_setDelegate(java.lang.Object _delegate)

		delegate = (DownloadManager)_delegate;
	
public java.lang.Object_setLocal()

		return( _fixupLocal());
	
public DownloadaddDownload(Torrent torrent)

		try{
			RPDownload	res = (RPDownload)_dispatcher.dispatch( new RPRequest( this, "addDownload[Torrent]", new Object[]{torrent})).getResponse();
			
			res._setRemote( _dispatcher );
		
			return( res );
			
		}catch( RPException e ){
			
			if ( e.getCause() instanceof DownloadException ){
				
				throw((DownloadException)e.getCause());
			}
			
			throw( e );
		}	
	
public DownloadaddDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location)

		try{
			RPDownload	res = (RPDownload)_dispatcher.dispatch( 
					new RPRequest( this, "addDownload[Torrent,String,String]", 
							new Object[]{
								torrent,
								torrent_location==null?null:torrent_location.toString(),
								data_location==null?null:data_location.toString(),
							})).getResponse();
			
			res._setRemote( _dispatcher );
		
			return( res );
			
		}catch( RPException e ){
			
			if ( e.getCause() instanceof DownloadException ){
				
				throw((DownloadException)e.getCause());
			}
			
			throw( e );
		}	
	
public voidaddDownload(java.io.File torrent_file)

		notSupported();
	
public voidaddDownload(java.net.URL url, java.net.URL referer)

		notSupported();
	
public voidaddDownload(java.net.URL url)

		_dispatcher.dispatch( new RPRequest( this, "addDownload[URL]", new Object[]{url} )).getResponse();
	
public voidaddDownload(java.net.URL url, boolean auto_download)

		notSupported();
	
public DownloadaddDownloadStopped(Torrent torrent, java.io.File torrent_location, java.io.File data_location)

		notSupported();
		
		return( null );
	
public voidaddDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)

		notSupported();
	
public voidaddListener(DownloadManagerListener l)

		notSupported();
	
public voidaddListener(DownloadManagerListener l, boolean notify)

		notSupported();
	
public DownloadaddNonPersistentDownload(Torrent torrent, java.io.File torrent_location, java.io.File data_location)

		notSupported();
		
		return( null );
	
public booleancanPauseDownloads()

		notSupported();
		
		return false;
	
public booleancanResumeDownloads()

		notSupported();
		
		return false;
	
public static org.gudy.azureus2.pluginsimpl.remote.download.RPDownloadManagercreate(DownloadManager _delegate)

		RPDownloadManager	res =(RPDownloadManager)_lookupLocal( _delegate );
		
		if ( res == null ){
			
			res = new RPDownloadManager( _delegate );
		}
		
		return( res );
	
public DownloadgetDownload(Torrent torrent)

		notSupported();
		
		return( null );
	
public DownloadgetDownload(byte[] hash)

		notSupported();
		
		return( null );
	
public Download[]getDownloads()

		RPDownload[]	res = (RPDownload[])_dispatcher.dispatch( new RPRequest( this, "getDownloads", null )).getResponse();
		
		for (int i=0;i<res.length;i++){
			
			res[i]._setRemote( _dispatcher );
		}
		
		return( res );
	
public Download[]getDownloads(boolean bSort)

		RPDownload[]	res = (RPDownload[])_dispatcher.dispatch( new RPRequest( this, "getDownloads[boolean]", new Object[]{ new Boolean(bSort)} )).getResponse();
		
		for (int i=0;i<res.length;i++){
			
			res[i]._setRemote( _dispatcher );
		}
		
		return( res );
	
public DownloadEventNotifiergetGlobalDownloadEventNotifier()

		notSupported();
		return null;
	
public DownloadManagerStatsgetStats()

		notSupported();
		
		return( null );
	
public booleanisSeedingOnly()

		notSupported();
		
		return( false );
	
public voidpauseDownloads()

		_dispatcher.dispatch( new RPRequest( this, "pauseDownloads", null )).getResponse();
	
public voidremoveDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)

		notSupported();
	
public voidremoveListener(DownloadManagerListener l)

		notSupported();
	
public voidremoveListener(DownloadManagerListener l, boolean notify)

		notSupported();
	
public voidresumeDownloads()

		_dispatcher.dispatch( new RPRequest( this, "resumeDownloads", null )).getResponse();
	
public voidstartAllDownloads()

		_dispatcher.dispatch( new RPRequest( this, "startAllDownloads", null )).getResponse();
	
public voidstopAllDownloads()

		_dispatcher.dispatch( new RPRequest( this, "stopAllDownloads", null )).getResponse();