FileDocCategorySizeDatePackage
TorrentDownloaderManager.javaAPI DocAzureus 3.0.3.44898Thu Feb 09 19:43:18 GMT 2006org.gudy.azureus2.core3.torrentdownloader.impl

TorrentDownloaderManager

public class TorrentDownloaderManager extends Object implements org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderCallBackInterface
author
Tobias Minich

Fields Summary
private static TorrentDownloaderManager
man
private boolean
logged
private boolean
autostart
private org.gudy.azureus2.core3.global.GlobalManager
gm
private String
downloaddir
private ArrayList
running
private ArrayList
queued
private ArrayList
errors
Constructors Summary
public TorrentDownloaderManager()

    
      
        try {
            downloaddir = COConfigurationManager.getDirectoryParameter("Default save path");
        } catch (Exception e) {
            //this.error = e.getMessage();
            downloaddir = null;
        }
    
Methods Summary
public voidTorrentDownloaderEvent(int state, org.gudy.azureus2.core3.torrentdownloader.TorrentDownloader inf)

        switch(state) {
            case TorrentDownloader.STATE_START:
                if (this.queued.contains(inf))
                    this.queued.remove(inf);
                if (!this.running.contains(inf))
                    this.running.add(inf);
                break;
            case TorrentDownloader.STATE_FINISHED:
                remove(inf);
                if ((gm != null) && (downloaddir != null)) {
                    gm.addDownloadManager(inf.getFile().getAbsolutePath(), downloaddir);
                }
                break;
            case TorrentDownloader.STATE_ERROR:
                remove(inf);
                this.errors.add(inf);
                break;
        }
    
public org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderadd(org.gudy.azureus2.core3.torrentdownloader.TorrentDownloader dl)

        if (dl.getDownloadState()==TorrentDownloader.STATE_ERROR)
            this.errors.add(dl);
        else if (this.running.contains(dl) || this.queued.contains(dl)) {
            ((TorrentDownloaderImpl) dl).setDownloadState(TorrentDownloader.STATE_DUPLICATE);
            ((TorrentDownloaderImpl) dl).notifyListener();
            this.errors.add(dl);
        } else if (this.autostart) {
            dl.start();
        } else
            this.queued.add(dl);
        return dl;
    
public org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderdownload(java.lang.String url, java.lang.String fileordir, boolean logged)

        return add(TorrentDownloaderFactory.create(this, url, null, fileordir, logged));
    
public org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderdownload(java.lang.String url, boolean logged)

        return add(TorrentDownloaderFactory.create(this, url, null, null, logged));
    
public org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderdownload(java.lang.String url, java.lang.String fileordir)

        return add(TorrentDownloaderFactory.create(this, url, null, fileordir, this.logged));
    
public org.gudy.azureus2.core3.torrentdownloader.TorrentDownloaderdownload(java.lang.String url)

        return add(TorrentDownloaderFactory.create(this, url, this.logged));
    
public static org.gudy.azureus2.core3.torrentdownloader.impl.TorrentDownloaderManagergetInstance()

        if (man==null)
            man = new TorrentDownloaderManager();
        return man;
    
public voidinit(org.gudy.azureus2.core3.global.GlobalManager _gm, boolean _logged, boolean _autostart, java.lang.String _downloaddir)

        this.gm = _gm;
        this.logged = _logged;
        this.autostart = _autostart;
        if (_downloaddir != null)
            this.downloaddir = _downloaddir;
    
public voidremove(org.gudy.azureus2.core3.torrentdownloader.TorrentDownloader inf)

param
inf

		if (this.running.contains(inf))
		    this.running.remove(inf);
		if (this.queued.contains(inf))
		    this.queued.remove(inf);